class Apia::Object
Attributes
value[R]
Return the raw value object for this type
@return [Object, Hash]
Public Class Methods
collate_objects(set)
click to toggle source
Collate all objects that this type references and add them to the given object set
@param set [Apia::ObjectSet] @return [void]
# File lib/apia/object.rb, line 26 def collate_objects(set) definition.fields.each_value do |field| set.add_object(field.type.klass) if field.type.usable_for_field? end end
definition()
click to toggle source
Return the definition for this type
@return [Apia::Definitions::Object]
# File lib/apia/object.rb, line 17 def definition @definition ||= Definitions::Object.new(Helpers.class_name_to_id(name)) end
new(value)
click to toggle source
Initialize an instance of this type with the value provided
@param value [Object, Hash] @return [Apia::Object]
# File lib/apia/object.rb, line 38 def initialize(value) @value = value end
Public Instance Methods
hash(request: nil, path: [])
click to toggle source
Generate a hash based on the fields defined in this type
@param request [Apia::Request] the associated request @return [Hash]
# File lib/apia/object.rb, line 51 def hash(request: nil, path: []) self.class.definition.fields.generate_hash(@value, request: request, path: path) end
include?(request)
click to toggle source
Should this type be included in any output?
@param request [Apia::Request] @return [Boolean]
# File lib/apia/object.rb, line 59 def include?(request) return true if self.class.definition.conditions.empty? self.class.definition.conditions.all? do |cond| cond.call(@value, request) == true end end