Class: DataMapper::TypeMap::TypeChain
- Defined in:
- lib/gems/dm-core-0.9.9/lib/dm-core/type_map.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#primitive ⇒ Object
Returns the value of attribute primitive.
Instance Method Summary collapse
-
#initialize ⇒ TypeChain
constructor
A new instance of TypeChain.
- #to(primitive) ⇒ Object
- #translate ⇒ Object
- #with(attributes) ⇒ Object
Constructor Details
#initialize ⇒ TypeChain
Returns a new instance of TypeChain.
54 55 56 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/type_map.rb', line 54 def initialize @attributes = {} end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
52 53 54 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/type_map.rb', line 52 def attributes @attributes end |
#primitive ⇒ Object
Returns the value of attribute primitive.
52 53 54 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/type_map.rb', line 52 def primitive @primitive end |
Instance Method Details
#to(primitive) ⇒ Object
58 59 60 61 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/type_map.rb', line 58 def to(primitive) @primitive = primitive self end |
#translate ⇒ Object
69 70 71 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/type_map.rb', line 69 def translate @attributes.merge((@primitive.nil? ? {} : {:primitive => @primitive})) end |
#with(attributes) ⇒ Object
63 64 65 66 67 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/type_map.rb', line 63 def with(attributes) raise "method 'with' expects a hash" unless attributes.kind_of?(Hash) @attributes.merge!(attributes) self end |