Sha256: 90b16a403a6f766b440a9d698517910d340f21c8b0950afd80893df75d1554bd

Contents?: true

Size: 824 Bytes

Versions: 8

Compression:

Stored size: 824 Bytes

Contents

module StripeLocal
  class Card < ActiveRecord::Base
    self.primary_key = :id

    has_many   :charges,  inverse_of:  :card
    belongs_to :customer, inverse_of:  :cards

    class<<self
      def create attrs_hash
        super normalize( attrs_hash )
      end

      def normalize hash
        hash.each_with_object({}) do |(k,v),h|
          key = case k.to_sym
          when :customer then :customer_id
          when :type     then :brand
          when ->(x){attribute_method? x} then k.to_sym
          else next
          end
          h[key] = v
        end
      end
    end

  # =!=#>>>
  # string   :id
  # string   :customer_id
  # string   :name
  # integer  :exp_month
  # integer  :exp_year
  # string   :brand
  # string   :last4
  # string   :cvc_check
  # string   :fingerprint
  # =ยก=#>>>
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
stripe_local-0.2.5 app/models/stripe_local/card.rb
stripe_local-0.2.4 app/models/stripe_local/card.rb
stripe_local-0.2.3 app/models/stripe_local/card.rb
stripe_local-0.2.2 app/models/stripe_local/card.rb
stripe_local-0.2.1 app/models/stripe_local/card.rb
stripe_local-0.2.0 app/models/stripe_local/card.rb
stripe_local-0.1.3 app/models/stripe_local/card.rb
stripe_local-0.1.2 app/models/stripe_local/card.rb