valuable
valuable copied to clipboard
Model.new(a).to_hash.should == a
Implement the following test:
class Valuable
def to_hash
attributes.to_hash
end
end
class Phone < Valuable
has_value :area_code
has_value :exchange
has_value :last_four
end
class Person < Valuable
has_value :name
has_value :age
has_collection :phones, :klass => Phone
end
a = {
name: 'Dylan',
age: 'teenager / rude',
phones: [
{
area_code: '111',
exchange: '234',
last_four: '4567'
},
]
}
Person.new(a).to_hash.should == a