I have more attributes in my hash than Virtus has defined in it's class. I want to cull those attributes inside the virtus model before instantiating it.
test_hash = {:x="stuff" , :y ="stuff2", :z="stuff3"}
def myObject
include Virtus.model
attribute :x, String
attribute :y, String
end
myObject.new(test_hash)
This fails with a NoMethodError: undefined method 'z='
I just want it to silently discard z and still create the object.
I tried overriding the initialize method and inserting a culling method, but that didn't appear to work. Apparently mass assigning attributes goes through a different pathway during object create?
Best way to go about culling these attributes?
Seems to work okay with 1.0.5; which version are you on?