Sha256: 3e68fbb1342ee4e050c3261e5f226dd1df3d0485fda69140517c83c7f002a502

Contents?: true

Size: 582 Bytes

Versions: 35

Compression:

Stored size: 582 Bytes

Contents

module DiscoApp::Concerns::Plan
  extend ActiveSupport::Concern

  included do

    has_many :subscriptions
    has_many :shops, through: :subscriptions
    has_many :plan_codes, dependent: :destroy

    accepts_nested_attributes_for :plan_codes, allow_destroy: true

    enum status: [:available, :unavailable]
    enum plan_type: [:recurring, :one_time]
    enum interval: [:month, :year]

    scope :available, -> { where status: statuses[:available] }

    validates_presence_of :name

  end

  def has_trial?
    trial_period_days.present? and trial_period_days > 0
  end

end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
disco_app-0.9.0 app/models/disco_app/concerns/plan.rb
disco_app-0.9.1 app/models/disco_app/concerns/plan.rb
disco_app-0.9.2 app/models/disco_app/concerns/plan.rb
disco_app-0.9.3 app/models/disco_app/concerns/plan.rb
disco_app-0.9.4 app/models/disco_app/concerns/plan.rb
disco_app-0.9.5 app/models/disco_app/concerns/plan.rb
disco_app-0.9.6 app/models/disco_app/concerns/plan.rb
disco_app-0.9.7 app/models/disco_app/concerns/plan.rb
disco_app-0.9.8 app/models/disco_app/concerns/plan.rb
disco_app-0.9.9 app/models/disco_app/concerns/plan.rb
disco_app-0.9.10 app/models/disco_app/concerns/plan.rb
disco_app-0.9.11 app/models/disco_app/concerns/plan.rb
disco_app-0.10.0 app/models/disco_app/concerns/plan.rb
disco_app-0.10.1 app/models/disco_app/concerns/plan.rb
disco_app-0.10.2 app/models/disco_app/concerns/plan.rb
disco_app-0.10.3 app/models/disco_app/concerns/plan.rb
disco_app-0.10.4 app/models/disco_app/concerns/plan.rb
disco_app-0.10.5 app/models/disco_app/concerns/plan.rb
disco_app-0.11.0 app/models/disco_app/concerns/plan.rb
disco_app-0.11.1 app/models/disco_app/concerns/plan.rb