Module: EffectiveCpdUser

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/effective_cpd_user.rb

Overview

EffectiveCpdUser

Mark your user model with effective_cpd_user to get a few helpers And user specific point required scores

Defined Under Namespace

Modules: Base, ClassMethods

Instance Method Summary collapse

Instance Method Details

#build_cpd_statement(cpd_cycle:) ⇒ Object

Find or build



67
68
69
70
# File 'app/models/concerns/effective_cpd_user.rb', line 67

def build_cpd_statement(cpd_cycle:)
  raise('expected an CpdCycle') unless cpd_cycle.class.respond_to?(:effective_cpd_cycle?)
  cpd_statement(cpd_cycle: cpd_cycle) || cpd_statements.build(cpd_cycle: cpd_cycle)
end

#cpd_audit_cpd_required?Boolean



53
54
55
# File 'app/models/concerns/effective_cpd_user.rb', line 53

def cpd_audit_cpd_required?
  true
end

#cpd_audit_reviewer?Boolean



57
58
59
# File 'app/models/concerns/effective_cpd_user.rb', line 57

def cpd_audit_reviewer?
  roles.include?(:cpd_audit_reviewer)
end

#cpd_statement(cpd_cycle:) ⇒ Object



61
62
63
64
# File 'app/models/concerns/effective_cpd_user.rb', line 61

def cpd_statement(cpd_cycle:)
  raise('expected an CpdCycle') unless cpd_cycle.class.respond_to?(:effective_cpd_cycle?)
  cpd_statements.find { |cpd_statement| cpd_statement.cpd_cycle_id == cpd_cycle.id }
end

#cpd_statement_required_score(cpd_statement) ⇒ Object

This one will actually be enforced or displayed first



43
44
45
# File 'app/models/concerns/effective_cpd_user.rb', line 43

def cpd_statement_required_score(cpd_statement)
  nil
end

#cpd_statement_targeted_score(cpd_statement) ⇒ Object

This one will be displayed on the sidebar if first one is nil Won’t actually block the submission



49
50
51
# File 'app/models/concerns/effective_cpd_user.rb', line 49

def cpd_statement_targeted_score(cpd_statement)
  nil
end