diff --git a/lib/stripe/stripe_object.rb b/lib/stripe/stripe_object.rb index 4ea943e5..2b0509b2 100644 --- a/lib/stripe/stripe_object.rb +++ b/lib/stripe/stripe_object.rb @@ -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) diff --git a/test/stripe/stripe_object_test.rb b/test/stripe/stripe_object_test.rb index a5246a0c..b9598124 100644 --- a/test/stripe/stripe_object_test.rb +++ b/test/stripe/stripe_object_test.rb @@ -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')