Skip to content
Browse files

Pass model to the representation block

  • Loading branch information...
1 parent a4125b5 commit dfc4eeaf30397da5370631b77a41ddd6b600bae1 @jhchabran jhchabran committed Jul 23, 2012
Showing with 6 additions and 5 deletions.
  1. +1 −1 lib/vintner/builder.rb
  2. +1 −1 lib/vintner/importer.rb
  3. +4 −3 spec/vintner/representer_spec.rb
View
2 lib/vintner/builder.rb
@@ -7,7 +7,7 @@ def export representer, model
@model = model
# Registering keys and properties
- @block.call(self) if @block
+ @block.call(self, @model) if @block
hash = {}
View
2 lib/vintner/importer.rb
@@ -7,7 +7,7 @@ def import representer, model, hash
@model = model
# Registering keys and properties
- @block.call(self) if @block
+ @block.call(self, @model) if @block
# Then we play the score accordingly
@store.each do |key, object|
View
7 spec/vintner/representer_spec.rb
@@ -141,8 +141,8 @@ class Dummy
describe "Immediate values" do
before :each do
- @hash = {:meta=>{:version => 4, :title => "test"}}
- @model = Struct.new(:formatted_title).new("test")
+ @hash = {:meta=>{:version => 4, :title => "test", :stuff => "stuff"}}
+ @model = Struct.new(:formatted_title, :stuff).new("test", "stuff")
class Dummy
include Vintner::Representer
@@ -157,10 +157,11 @@ class Dummy
end
end
- representation do |json|
+ representation do |json, model|
json.meta do |meta|
meta.version 4
meta.property :title
+ meta.stuff model.stuff
end
end
end

0 comments on commit dfc4eea

Please sign in to comment.
Something went wrong with that request. Please try again.