Class: Plan

Inherits:
ApplicationRecord show all
Defined in:
app/models/plan.rb

Constant Summary collapse

DEFAULT =
'default'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Class Method Details

.all_plansObject


21
22
23
# File 'app/models/plan.rb', line 21

def self.all_plans
  ALL_PLANS
end

.defaultObject

This always returns an object


13
14
15
16
17
18
19
# File 'app/models/plan.rb', line 13

def self.default
  Gitlab::SafeRequestStore.fetch(:plan_default) do
    # find_by allows us to find object (cheaply) against replica DB
    # safe_find_or_create_by does stick to primary DB
    find_by(name: DEFAULT) || safe_find_or_create_by(name: DEFAULT)
  end
end

.default_plansObject


25
26
27
# File 'app/models/plan.rb', line 25

def self.default_plans
  DEFAULT_PLANS
end

Instance Method Details

#actual_limitsObject


29
30
31
# File 'app/models/plan.rb', line 29

def actual_limits
  self.limits || self.build_limits
end

#default?Boolean

Returns:

  • (Boolean)

33
34
35
# File 'app/models/plan.rb', line 33

def default?
  self.class.default_plans.include?(name)
end

#paid?Boolean

Returns:

  • (Boolean)

37
38
39
# File 'app/models/plan.rb', line 37

def paid?
  false
end