Class: Plan

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

Constant Summary collapse

DEFAULT =
'default'

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Class Method Details

.all_plansObject



23
24
25
# File 'app/models/plan.rb', line 23

def self.all_plans
  ALL_PLANS
end

.defaultObject

This always returns an object



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

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) { |plan| plan.title = DEFAULT.titleize }
  end
end

.default_plansObject



27
28
29
# File 'app/models/plan.rb', line 27

def self.default_plans
  DEFAULT_PLANS
end

Instance Method Details

#actual_limitsObject



31
32
33
# File 'app/models/plan.rb', line 31

def actual_limits
  self.limits || self.build_limits
end

#default?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'app/models/plan.rb', line 35

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

#paid?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'app/models/plan.rb', line 39

def paid?
  false
end