Class: Bluepine::Attributes::SchemaAttribute

Inherits:
ObjectAttribute show all
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

Attributes inherited from ObjectAttribute

#attributes

Attributes inherited from Attribute

#name

Instance Method Summary collapse

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

#validators

Methods included from Validators::Normalizable

#normalize

Methods included from Serializers::Serializable

#serialize

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, options = {})
  # automatically add name to :of if it's not given
  options[:of] = name unless options.key?(:of)
  @expandable  = options.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

#expandableObject (readonly)

Returns the value of attribute expandable.



20
21
22
# File 'lib/bluepine/attributes/schema_attribute.rb', line 20

def expandable
  @expandable
end