Class: DataMapper::TypeMap::TypeChain

Inherits:
Object
  • Object
show all
Defined in:
lib/gems/dm-core-0.9.9/lib/dm-core/type_map.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTypeChain

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

#attributesObject

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

#primitiveObject

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

#translateObject



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