lib/virtus/attribute/embedded_value.rb in virtus-0.2.0 vs lib/virtus/attribute/embedded_value.rb in virtus-0.3.0

- old
+ new

@@ -23,42 +23,31 @@ # # user = User.new(:address => { # :street => 'Street 1/2', :zipcode => '12345', :city => 'NYC' }) # class EmbeddedValue < Object + primitive ::OpenStruct # @see Attribute.merge_options # # @return [Hash] # an updated options hash for configuring an EmbeddedValue instance # # @api private def self.merge_options(type, options) - options.merge(:model => type) + options.merge(:primitive => type) end - # Sets @model ivar - # - # @see Virtus::Attribute#initialize - # - # @return [undefined] - # - # @api private - def initialize(name, options = {}) - super - @model = options.fetch(:model, OpenStruct) - end - # Coerce attributes into a virtus object # # @param [Hash,Virtus] # # @return [Virtus] # # @api private def coerce(attributes_or_object) value = if attributes_or_object.kind_of?(::Hash) - @model.new(attributes_or_object) + @primitive.new(attributes_or_object) else attributes_or_object end super(value)