Class: Apia::Object
- Inherits:
-
Object
- Object
- Apia::Object
- Extended by:
- Defineable
- Defined in:
- lib/apia/object.rb
Direct Known Subclasses
PaginationObject, Schema::APIControllerSchemaType, Schema::APISchemaType, Schema::ArgumentSchemaType, Schema::ArgumentSetSchemaType, Schema::AuthenticatorSchemaType, Schema::ControllerEndpointSchemaType, Schema::ControllerSchemaType, Schema::EndpointSchemaType, Schema::EnumSchemaType, Schema::EnumValueSchemaType, Schema::ErrorSchemaType, Schema::FieldSchemaType, Schema::FieldSpecOptionsSchemaType, Schema::LookupArgumentSetSchemaType, Schema::ObjectSchemaType, Schema::PolymorphOptionSchemaType, Schema::PolymorphSchemaType, Schema::RouteGroupSchemaType, Schema::RouteSchemaType, Schema::RouteSetSchemaType, Schema::ScalarSchemaType, Schema::ScopeType
Instance Attribute Summary collapse
-
#value ⇒ Object, Hash
readonly
Return the raw value object for this type.
Class Method Summary collapse
-
.collate_objects(set) ⇒ void
Collate all objects that this type references and add them to the given object set.
-
.definition ⇒ Apia::Definitions::Object
Return the definition for this type.
Instance Method Summary collapse
-
#hash(request: nil, path: []) ⇒ Hash
Generate a hash based on the fields defined in this type.
-
#include?(request) ⇒ Boolean
Should this type be included in any output?.
-
#initialize(value) ⇒ Apia::Object
constructor
Initialize an instance of this type with the value provided.
Methods included from Defineable
create, inspect, method_missing, name, respond_to_missing?
Constructor Details
#initialize(value) ⇒ Apia::Object
Initialize an instance of this type with the value provided
38 39 40 |
# File 'lib/apia/object.rb', line 38 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object, Hash (readonly)
Return the raw value object for this type
45 46 47 |
# File 'lib/apia/object.rb', line 45 def value @value end |
Class Method Details
.collate_objects(set) ⇒ void
This method returns an undefined value.
Collate all objects that this type references and add them to the given object set
26 27 28 29 30 |
# 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 ⇒ Apia::Definitions::Object
Return the definition for this type
17 18 19 |
# File 'lib/apia/object.rb', line 17 def definition @definition ||= Definitions::Object.new(Helpers.class_name_to_id(name)) end |
Instance Method Details
#hash(request: nil, path: []) ⇒ Hash
Generate a hash based on the fields defined in this type
51 52 53 |
# File 'lib/apia/object.rb', line 51 def hash(request: nil, path: []) self.class.definition.fields.generate_hash(@value, object: self, request: request, path: path) end |
#include?(request) ⇒ Boolean
Should this type be included in any output?
59 60 61 62 63 64 65 |
# 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 |