Sha256: 9b53946b62bf4a14a2ac8abfa82406e3f1230e97b47d6f13ef2347906aaf709f

Contents?: true

Size: 689 Bytes

Versions: 7

Compression:

Stored size: 689 Bytes

Contents

module DiscoApp::Concerns::Plan

  extend ActiveSupport::Concern

  included do
    has_many :subscriptions, dependent: :restrict_with_exception
    has_many :shops, through: :subscriptions
    has_many :plan_codes, dependent: :destroy

    accepts_nested_attributes_for :plan_codes, allow_destroy: true

    enum status: {
      available: 0,
      unavailable: 1
    }
    enum plan_type: {
      recurring: 0,
      one_time: 1
    }
    enum interval: {
      month: 0,
      year: 1
    }

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

    validates_presence_of :name
  end

  def has_trial?
    trial_period_days.present? && trial_period_days.positive?
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
disco_app-0.17.0 app/models/disco_app/concerns/plan.rb
disco_app-0.18.0 app/models/disco_app/concerns/plan.rb
disco_app-0.18.2 app/models/disco_app/concerns/plan.rb
disco_app-0.18.3 app/models/disco_app/concerns/plan.rb
disco_app-0.18.6 app/models/disco_app/concerns/plan.rb
disco_app-0.18.4 app/models/disco_app/concerns/plan.rb
disco_app-0.18.1 app/models/disco_app/concerns/plan.rb