Class: DataMapper::Property::Object

Inherits:
DataMapper::Property show all
Defined in:
lib/dm-core/property/object.rb

Direct Known Subclasses

Boolean, Class, Date, DateTime, Numeric, String, Time

Constant Summary

Constant Summary

Constants inherited from DataMapper::Property

INVALID_NAMES, OPTIONS, PRIMITIVES, VISIBILITY_OPTIONS

Instance Attribute Summary

Attributes inherited from DataMapper::Property

#allow_blank, #allow_nil, #coercion_method, #default, #dump_as, #index, #instance_variable_name, #load_as, #model, #name, #options, #reader_visibility, #repository_name, #required, #unique_index, #writer_visibility

Instance Method Summary (collapse)

Methods inherited from DataMapper::Property

accept_options, accepted_options, #allow_blank?, #allow_nil?, #assert_valid_options, #assert_valid_value, #bind, demodulized_names, descendants, determine_class, #determine_visibility, #field, find_class, #get, #get!, inherited, #initialize, #inspect, #key?, #lazy?, #lazy_load, #lazy_load_properties, #loaded?, nullable, options, primitive, #primitive, #primitive?, #properties, #required?, #serial?, #set, #set!, #typecast, #unique?, #valid?, #value_dumped?, #value_loaded?

Methods included from Deprecate

#deprecate

Methods included from Equalizer

#equalize

Methods included from Subject

#default?, #default_for

Methods included from Assertions

#assert_kind_of

Constructor Details

This class inherits a constructor from DataMapper::Property

Instance Method Details

- (Object) dump(value)



9
10
11
# File 'lib/dm-core/property/object.rb', line 9

def dump(value)
  instance_of?(Object) ? marshal(value) : value
end

- (Object) load(value)



14
15
16
# File 'lib/dm-core/property/object.rb', line 14

def load(value)
  typecast(instance_of?(Object) ? unmarshal(value) : value)
end

- (Object) marshal(value)



19
20
21
# File 'lib/dm-core/property/object.rb', line 19

def marshal(value)
  [ Marshal.dump(value) ].pack('m') unless value.nil?
end

- (Object) to_child_key

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/dm-core/property/object.rb', line 29

def to_child_key
  self.class
end

- (Object) unmarshal(value)



24
25
26
# File 'lib/dm-core/property/object.rb', line 24

def unmarshal(value)
  Marshal.load(value.unpack('m').first) unless value.nil?
end