module StripeLocal module ObjectAdapter extend ActiveSupport::Concern module ClassMethods def find_remote id object = stripe_object.retrieve id new object end # read access to stripe object def stripe_object @stripe_object ||= Object.qualified_const_get "Stripe::#{self.to_s.classify}" end #=!=# # 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. #=ยก=# 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 end end end