mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-05-31 00:00:37 -04:00
Merge pull request #528 from iamvery/iamvery/add-boolean-predicates-when-accessor-is-missing
Include predicate for lazily added boolean accessors
This commit is contained in:
commit
34b524547a
@ -262,9 +262,10 @@ module Stripe
|
||||
# TODO: only allow setting in updateable classes.
|
||||
if name.to_s.end_with?('=')
|
||||
attr = name.to_s[0...-1].to_sym
|
||||
val = args.first
|
||||
|
||||
# the second argument is only required when adding boolean accessors
|
||||
add_accessors([attr], {})
|
||||
add_accessors([attr], { attr => val })
|
||||
|
||||
begin
|
||||
mth = method(name)
|
||||
|
@ -80,6 +80,13 @@ module Stripe
|
||||
refute obj.respond_to?(:not_bool?)
|
||||
end
|
||||
|
||||
should "assign question mark accessors for booleans added after initialization" do
|
||||
obj = Stripe::StripeObject.new
|
||||
obj.bool = true
|
||||
assert obj.respond_to?(:bool?)
|
||||
assert obj.bool?
|
||||
end
|
||||
|
||||
should "mass assign values with #update_attributes" do
|
||||
obj = Stripe::StripeObject.construct_from({ :id => 1, :name => 'Stripe' })
|
||||
obj.update_attributes(:name => 'STRIPE')
|
||||
|
Loading…
x
Reference in New Issue
Block a user