Skip to content

Commit 62f6825

Browse files
committed
Merge pull request #165 from marshall-lee/fix_entity_private_methods_master
Fix: entity instance methods exposure.
2 parents 0dfe7ac + 5e38abc commit 62f6825

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
* [#151](https://github.com/intridea/grape-entity/pull/151): Fix: deep projections (`:only`, `:except`) were unaware of nesting: [#156](https://github.com/intridea/grape-entity/issues/156) - [@marshall-lee](https://github.com/marshall-lee).
1515
* Your contribution here.
1616

17+
0.4.7 (2015-08-03)
18+
==================
19+
* [#164](https://github.com/intridea/grape-entity/pull/164): Regression: entity instance methods were exposed with `NoMethodError`: [#163](https://github.com/intridea/grape-entity/issues/163) - [@marshall-lee](http://github.com/marshall-lee).
20+
1721
0.4.6 (2015-07-27)
1822
==================
1923

lib/grape_entity/exposure/base.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def deep_complex_nesting?
4646
end
4747

4848
def valid?(entity)
49-
is_delegatable = entity.delegator.delegatable?(@attribute)
49+
is_delegatable = entity.delegator.delegatable?(@attribute) || entity.respond_to?(@attribute, true)
5050
if @is_safe
5151
is_delegatable
5252
else

spec/grape_entity/entity_spec.rb

+4
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,10 @@ def name
14671467
rep = EntitySpec::DelegatingEntity.new(friend)
14681468
expect(rep.value_for(:name)).to eq 'cooler name'
14691469
expect(rep.value_for(:email)).to eq '[email protected]'
1470+
1471+
another_friend = double('Friend', email: '[email protected]')
1472+
rep = EntitySpec::DelegatingEntity.new(another_friend)
1473+
expect(rep.value_for(:name)).to eq 'cooler name'
14701474
end
14711475

14721476
context 'using' do

0 commit comments

Comments
 (0)