apotonick/roar — Issue #8: Cannot reproduce README example
Author: janlelis
Created: 2012-01-06 15:44:49+00:00
State: open

Hi Nick,

I've got a problem trying out the README example using the following versions:

* roar: 0.9.1
* representable: 1.0.1
* ruby: 1.9.3p0

Code

require 'roar/representer/json'
require 'roar/representer/feature/hypermedia'

class Article
include Roar::Representer::JSON
include Roar::Representer::Feature::Hypermedia

property :title
property :id

link :self do
article_url(represented)
end
end

Then running

Article.new(
title: "Lonestar",
id: 666)

leads to

ArgumentError: wrong number of arguments(1 for 0)
from (irb):15:in `initialize'
from (irb):15:in `new'

And

Article.from_hash(
title: "Lonestar",
id: 666)

leads to

NoMethodError: undefined method `title=' for #
from /home/dan/.rvm/gems/ruby-1.9.3-p0/gems/representable-1.0.1/lib/representable.rb:54:in `block in update_properties_from'
from /home/dan/.rvm/gems/ruby-1.9.3-p0/gems/representable-1.0.1/lib/representable.rb:50:in `each'
from /home/dan/.rvm/gems/ruby-1.9.3-p0/gems/representable-1.0.1/lib/representable.rb:50:in `update_properties_from'
from /home/dan/.rvm/gems/ruby-1.9.3-p0/gems/representable-1.0.1/lib/representable/json.rb:47:in `from_hash'
from /home/dan/.rvm/gems/ruby-1.9.3-p0/gems/representable-1.0.1/lib/representable/json.rb:31:in `from_hash'