Permalink
Browse files

Use respond_to_missing? for OrderedOptions

  • Loading branch information...
1 parent 206b43a commit 3ea70f985b1799c27b907724920e5615018e505d @marcandre marcandre committed May 5, 2012
View
2 activesupport/lib/active_support/ordered_options.rb
@@ -36,7 +36,7 @@ def method_missing(name, *args)
end
end
- def respond_to?(name)
+ def respond_to_missing?(name, include_private)
@sobrinho
sobrinho added a line comment May 7, 2012

any benefit on using respond_to_missing? here since we don't call super?

@marcandre
marcandre added a line comment May 7, 2012

The benefit of using respond_to_missing? is not related to calling super or not. Please check http://blog.marc-andre.ca/2010/11/methodmissing-politely.html

@sobrinho
sobrinho added a line comment May 7, 2012

nice to know, thanks @marcandre! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
true
end
end
View
8 activesupport/test/ordered_options_test.rb
@@ -77,4 +77,12 @@ def test_inheritable_options_inheritable_copy
assert copy.kind_of?(original.class)
assert_not_equal copy.object_id, original.object_id
end
+
+ def test_introspection
+ a = ActiveSupport::OrderedOptions.new
+ assert a.respond_to?(:blah)
+ assert a.respond_to?(:blah=)
+ assert_equal 42, a.method(:blah=).call(42)
+ assert_equal 42, a.method(:blah).call
+ end
end

0 comments on commit 3ea70f9

Please sign in to comment.