Sha256: 0ac8276808f7fd0c3667fb0db41a9ba07724d45be38ea3cd91ed1368771b02c3
Contents?: true
Size: 968 Bytes
Versions: 11
Compression:
Stored size: 968 Bytes
Contents
class Wco::Price include Mongoid::Document include Mongoid::Timestamps include Mongoid::Paranoia store_in collection: 'wco_prices' # belongs_to :product, class_name: 'Wco::Product', inverse_of: :prices ## Wco::Product, WcoHosting::ApplianceTmpl: belongs_to :product, polymorphic: true # , foreign_key: :wco_price_id has_many :subscriptions, class_name: 'Wco::Subscription', inverse_of: :price, foreign_key: :wco_price_id field :amount_cents, type: Integer INTERVAL_DAY = 'day' INTERVAL_WEEK = 'week' INTERVAL_MONTH = 'month' INTERVAL_YEAD = 'year' INTERVALS = [ nil, 'day', 'week', 'month', 'year' ] field :interval, type: String field :price_id # stripe def to_s price = self "$#{ price[:amount_cents].to_f/100 }/#{ price.interval||'onetime' }" end def self.list [[nil,nil]] + all.map { |p| [ "#{p.product.name} :: #{p.amount_cents.to_f/100}/#{p.interval||'onetime'}", p.id ] } end end
Version data entries
11 entries across 11 versions & 1 rubygems