solnic / virtus

[DISCONTINUED ] Attributes on Steroids for Plain Old Ruby Objects
MIT License
3.77k stars 229 forks source link

Deep attributes #185

Closed nyarly closed 11 years ago

nyarly commented 11 years ago

Consider:

class Host
  include Virtus
  class Guest
    include Virtus
    attribute :one, String
  end
  attribute :guest, Guest
end

attrs = {:guest => {:one => "hi!}}
Host.new(attrs).attributes != attrs #because h.attributes[:guest] => #<Host::Guest> rather than {:one => "hi!"}

I'm not sure there's use cases for this "shallow" attributes behavior, but a "deep_attributes" method would be helpful.

solnic commented 11 years ago

@nyarly sorry this won't be added, in fact #attributes will probably be deprecated. Virtus is not a serialization library.