Module: StripeLocal::ObjectAdapter::ClassMethods
- Defined in:
- app/mixins/stripe_local/object_adapter.rb
Instance Method Summary collapse
- #find_remote(id) ⇒ Object
-
#stripe_object ⇒ Object
read access to stripe object.
-
#time_writer(*array_of_syms) ⇒ Object
!=# attr_accessor like
macro
for DateTime columns of a localized Stripe Object class to use: * Pass in one or more symbolized column names.
Instance Method Details
#find_remote(id) ⇒ Object
6 7 8 9 |
# File 'app/mixins/stripe_local/object_adapter.rb', line 6 def find_remote id object = stripe_object.retrieve id new object end |
#stripe_object ⇒ Object
read access to stripe object
12 13 14 |
# File 'app/mixins/stripe_local/object_adapter.rb', line 12 def stripe_object @stripe_object ||= Object.qualified_const_get "Stripe::#{self.to_s.classify}" end |
#time_writer(*array_of_syms) ⇒ Object
!=#
attr_accessor like macro
for DateTime columns of a localized Stripe Object class to use:
* Pass in one or more symbolized column names.
Generates setter methods for converting JSON style ‘epoch` timestamps to the proper DateTime values your database expects. Note:
Regular DateTime
objects are perfectly acceptable as arguments because the value is always coerced into an Integer
before conversion.
¡=#
23 24 25 26 27 28 29 |
# File 'app/mixins/stripe_local/object_adapter.rb', line 23 def time_writer *array_of_syms array_of_syms.each do |sym| define_method ":#{sym}=" do |epoch| write_attribute sym, Time.at( epoch.to_i ) unless epoch.nil? end end end |