Class: Virtus::Attribute::EmbeddedValue
- Inherits:
-
Object
- Object
- Virtus::Attribute
- Object
- Virtus::Attribute::EmbeddedValue
- Defined in:
- lib/virtus/attribute/embedded_value.rb
Overview
EmbeddedValue
Constant Summary
Constants included from TypeLookup
Instance Attribute Summary
Attributes inherited from Virtus::Attribute
#coercion_method, #default, #name, #options
Class Method Summary collapse
-
.merge_options(type, options) ⇒ Hash
private
An updated options hash for configuring an EmbeddedValue instance.
Instance Method Summary collapse
-
#coerce(attributes_or_object) ⇒ Virtus
private
Coerce attributes into a virtus object.
Methods inherited from Virtus::Attribute
build, #define_accessor_methods, #define_reader_method, #define_writer_method, determine_type, #get, #get!, #initialize, #inspect, #public_reader?, #public_writer?, #set, #set!, #value_coerced?
Methods included from DescendantsTracker
Methods included from TypeLookup
Methods included from Options
#accept_options, #accepted_options, #options
Constructor Details
This class inherits a constructor from Virtus::Attribute
Class Method Details
.merge_options(type, options) ⇒ Hash
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.
Returns an updated options hash for configuring an EmbeddedValue instance.
36 37 38 |
# File 'lib/virtus/attribute/embedded_value.rb', line 36 def self.(type, ) .merge(:primitive => type) end |
Instance Method Details
#coerce(attributes_or_object) ⇒ Virtus
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.
Coerce attributes into a virtus object
47 48 49 50 51 52 53 54 55 |
# File 'lib/virtus/attribute/embedded_value.rb', line 47 def coerce(attributes_or_object) value = if attributes_or_object.kind_of?(::Hash) @primitive.new(attributes_or_object) else attributes_or_object end super(value) end |