Skip to content

Commit

Permalink
Let the OutputBuilder be the Hash as well
Browse files Browse the repository at this point in the history
  • Loading branch information
sagebomb committed Jun 30, 2016
1 parent d65df18 commit 7d7797b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/grape_entity/exposure/nesting_exposure/output_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def add(exposure, result)
end
end

def kind_of?(klass)
klass == Hash || super
end
alias_method :is_a?, :kind_of?

def __getobj__
output
end
Expand Down
1 change: 1 addition & 0 deletions spec/grape_entity/entity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ class Parent < Person

representation = subject.represent(4.times.map { Object.new }, serializable: true)
expect(representation).to be_kind_of(Grape::Entity::Exposure::NestingExposure::OutputBuilder)
expect(representation).to be_kind_of(Hash)
expect(representation).to have_key :my_items
expect(representation[:my_items]).to be_kind_of Array
expect(representation[:my_items].size).to be 4
Expand Down

0 comments on commit 7d7797b

Please sign in to comment.