Skip to content

Commit

Permalink
Define Lotus::Presenter#respond_to_missing?
Browse files Browse the repository at this point in the history
  • Loading branch information
splattael committed Aug 1, 2014
1 parent e3e6089 commit b764cba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/lotus/presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,13 @@ def method_missing(m, *args, &blk)
super
end
end

# Override Ruby's respond_to_missing? in order to support proper delegation
#
# @api private
# @since x.x.x
def respond_to_missing?(m, include_private = false)
@object.respond_to?(m, include_private)
end
end
end
5 changes: 5 additions & 0 deletions test/presenter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
subject.inspect_object.must_match '#<Map'
end

it 'responds to whatever the object responds to' do
subject.must_respond_to :locations
subject.wont_respond_to :unknown_method
end

it "raises error when the requested method can't be satisfied" do
-> {
subject.unknown_method
Expand Down

0 comments on commit b764cba

Please sign in to comment.