Sha256: 7e249350ec295e1874dbaff7d2a807bc539ef0b8f01268420b97bfb0d3d80cf2
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
# == Attributes # subscriptions: all subscriptions for the plan # rate_cents: how much this plan costs, in cents # rate: how much this plan costs, in Money # yearly: whether this plan cycles yearly or monthly # module Freemium module SubscriptionPlan include Rates def self.included(base) base.class_eval do # yes, subscriptions.subscription_plan_id may not be null, but # this at least makes the delete not happen if there are any active. has_many :subscriptions, :dependent => :nullify, :class_name => "Subscription", :foreign_key => :subscription_plan_id has_and_belongs_to_many :coupons, :class_name => "SubscriptionPlan", :join_table => :coupons_subscription_plans, :foreign_key => :subscription_plan_id, :association_foreign_key => :coupon_id composed_of :rate, :class_name => 'Money', :mapping => [ %w(rate_cents cents) ], :allow_nil => true validates_uniqueness_of :redemption_key, :allow_nil => true, :allow_blank => true validates_presence_of :name validates_presence_of :rate_cents end end def features Freemium::FeatureSet.find(self.feature_set_id) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
freemium-0.0.2 | lib/freemium/subscription_plan.rb |
freemium-0.0.1 | lib/freemium/subscription_plan.rb |