Class: Bluepine::Attributes::SchemaAttribute
- Inherits:
-
ObjectAttribute
- Object
- Attribute
- ObjectAttribute
- Bluepine::Attributes::SchemaAttribute
- Defined in:
- lib/bluepine/attributes/schema_attribute.rb
Overview
Reference to other schema and doesn’t accept &block.
SchemaAttribute supports extra option named ‘expandable` which will either return `id` or `serialized object` as the result.
Constant Summary collapse
- DEFAULT_EXPANDABLE =
false
Constants included from Bluepine::Assertions
Bluepine::Assertions::Error, Bluepine::Assertions::KeyError, Bluepine::Assertions::SubsetError
Instance Attribute Summary collapse
-
#expandable ⇒ Object
readonly
Returns the value of attribute expandable.
Attributes inherited from ObjectAttribute
Attributes inherited from Attribute
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ SchemaAttribute
constructor
A new instance of SchemaAttribute.
Methods inherited from ObjectAttribute
#[], #[]=, #group, #keys, #method_missing, #native_type, #respond_to_missing?
Methods inherited from Attribute
#attributes, #default, #deprecated, #description, #format, #if, #in, #match, #method, #native_type, #null, #of, #options, #private, #required, #serializable?, #spec, #spec_uri, #type, #unless, #value
Methods included from Validators::Validatable
Methods included from Validators::Normalizable
Methods included from Serializers::Serializable
Methods included from Bluepine::Assertions
#assert, #assert_in, #assert_kind_of, #assert_not, #assert_subset_of, included
Constructor Details
#initialize(name, options = {}) ⇒ SchemaAttribute
Returns a new instance of SchemaAttribute.
12 13 14 15 16 17 18 |
# File 'lib/bluepine/attributes/schema_attribute.rb', line 12 def initialize(name, = {}) # automatically add name to :of if it's not given [:of] = name unless .key?(:of) @expandable = .fetch(:expandable, DEFAULT_EXPANDABLE) super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Bluepine::Attributes::ObjectAttribute
Instance Attribute Details
#expandable ⇒ Object (readonly)
Returns the value of attribute expandable.
20 21 22 |
# File 'lib/bluepine/attributes/schema_attribute.rb', line 20 def @expandable end |