Class: DataMapper::Property::Object
- Inherits:
-
DataMapper::Property
- Object
- DataMapper::Property
- DataMapper::Property::Object
- Defined in:
- lib/dm-core/property/object.rb
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, #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
- #dump(value) ⇒ Object
- #load(value) ⇒ Object
- #marshal(value) ⇒ Object
- #to_child_key ⇒ Object private
- #unmarshal(value) ⇒ Object
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 Equalizer
Methods included from Deprecate
Methods included from Subject
Methods included from Assertions
Constructor Details
This class inherits a constructor from DataMapper::Property
Instance Method Details
#dump(value) ⇒ Object
8 9 10 |
# File 'lib/dm-core/property/object.rb', line 8 def dump(value) instance_of?(Object) ? marshal(value) : value end |
#load(value) ⇒ Object
13 14 15 |
# File 'lib/dm-core/property/object.rb', line 13 def load(value) typecast(instance_of?(Object) ? unmarshal(value) : value) end |
#marshal(value) ⇒ Object
18 19 20 |
# File 'lib/dm-core/property/object.rb', line 18 def marshal(value) [ Marshal.dump(value) ].pack('m') unless value.nil? end |
#to_child_key ⇒ Object
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.
28 29 30 |
# File 'lib/dm-core/property/object.rb', line 28 def to_child_key self.class end |
#unmarshal(value) ⇒ Object
23 24 25 |
# File 'lib/dm-core/property/object.rb', line 23 def unmarshal(value) Marshal.load(value.unpack('m').first) unless value.nil? end |