mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-12-07 00:00:35 -05:00
Merge pull request #301 from stripe/brandur-symbolize-names
Perform deep name symbolization from .construct_from
This commit is contained in:
commit
f308bb3a52
@ -21,6 +21,7 @@ module Stripe
|
||||
end
|
||||
|
||||
def self.construct_from(values, opts={})
|
||||
values = Stripe::Util.symbolize_names(values)
|
||||
self.new(values[:id]).refresh_from(values, opts)
|
||||
end
|
||||
|
||||
|
||||
@ -9,6 +9,12 @@ module Stripe
|
||||
assert !obj.respond_to?(:baz)
|
||||
end
|
||||
|
||||
should "marshal be insensitive to strings vs. symbols when constructin" do
|
||||
obj = Stripe::StripeObject.construct_from({ :id => 1, 'name' => 'Stripe' })
|
||||
assert_equal 1, obj[:id]
|
||||
assert_equal 'Stripe', obj[:name]
|
||||
end
|
||||
|
||||
should "marshal a stripe object correctly" do
|
||||
obj = Stripe::StripeObject.construct_from({ :id => 1, :name => 'Stripe' }, {:api_key => 'apikey'})
|
||||
m = Marshal.load(Marshal.dump(obj))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user