app/models/stripe_local/customer.rb in stripe_local-0.2.0 vs app/models/stripe_local/customer.rb in stripe_local-0.2.1
- old
+ new
@@ -34,10 +34,11 @@
def normalize params
params.each_with_object({}) do |(k,v),h|
key = case k.to_sym
when :cards then create_each_card( v.data ) and next
when :subscription then create_subscription( v ) and next
+ when :metadata then h[:metadata] = MultiJson.dump( v.to_hash ) and next
when ->(x){attribute_method? x} then k.to_sym
else next
end
h[key] = v
end
@@ -50,9 +51,17 @@
end
def create_subscription object
StripeLocal::Subscription.create( object.to_hash ) unless object.nil?
end
+ end
+
+ def metadata= so
+ MultiJson.dump so.to_hash
+ end
+
+ def metadata
+ MultiJson.load read_attribute( :metadata ), symbolize_keys: true
end
#=!=>>>
# ~<Schema>~
# t.string :id