Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model.new(a).to_hash.should == a #18

Open
mustmodify opened this issue Jan 4, 2015 · 0 comments
Open

Model.new(a).to_hash.should == a #18

mustmodify opened this issue Jan 4, 2015 · 0 comments

Comments

@mustmodify
Copy link
Owner

mustmodify commented Jan 4, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant