Fall back to #respond_to? if ruby version is lower than 1.9.2

This commit is contained in:
Thomas Brus 2014-01-03 00:54:31 +01:00 committed by Andrew Thorp
parent a4b12fac62
commit 6a7f705be3
2 changed files with 12 additions and 6 deletions

View File

@ -102,8 +102,14 @@ module Stripe
@values.each(&blk)
end
def respond_to_missing?(symbol, include_private = false)
@values.has_key?(symbol) || super
if RUBY_VERSION < '1.9.2'
def respond_to?(symbol)
@values.has_key(symbol) || super
end
else
def respond_to_missing?(symbol, include_private = false)
@values.has_key?(symbol) || super
end
end
protected

View File

@ -5,9 +5,9 @@ module Stripe
should "implement #respond_to correctly" do
obj = Stripe::StripeObject.construct_from({ :some_key => "something", :id => 123 })
assert obj.respond_to_missing?(:id)
assert obj.respond_to_missing?(:some_key)
assert !obj.respond_to_missing?(:some_other_key)
assert obj.respond_to?(:id)
assert obj.respond_to?(:some_key)
assert !obj.respond_to?(:some_other_key)
end
end
end
end