Sha256: b104a84027a4f03509f8b5fd6901e9c377e3233adcd2e9f6e3b35e512d52250b
Contents?: true
Size: 1.59 KB
Versions: 5
Compression:
Stored size: 1.59 KB
Contents
# EffectiveCpdUser # # Mark your user model with effective_cpd_user to get a few helpers # And user specific point required scores module EffectiveCpdUser extend ActiveSupport::Concern module Base def effective_cpd_user include ::EffectiveCpdUser end end included do has_many :cpd_statements, -> { Effective::CpdStatement.sorted }, inverse_of: :user, class_name: 'Effective::CpdStatement' has_many :cpd_audits, -> { Effective::CpdAudit.sorted }, inverse_of: :user, class_name: 'Effective::CpdAudit' has_many :cpd_audit_reviews, -> { Effective::CpdAuditReview.sorted }, inverse_of: :user, class_name: 'Effective::CpdAuditReview' accepts_nested_attributes_for :cpd_statements end # This one will actually be enforced or displayed first def cpd_statement_required_score(cpd_statement) nil end # This one will be displayed on the sidebar if first one is nil # Won't actually block the submission def cpd_statement_targeted_score(cpd_statement) nil end def cpd_audit_cpd_required? true end def cpd_statement(cpd_cycle:) raise('expected an Effective::CpdCycle') unless cpd_cycle.class.respond_to?(:effective_cpd_cpd_cycle?) cpd_statements.find { |cpd_statement| cpd_statement.cpd_cycle_id == cpd_cycle.id } end # Find or build def build_cpd_statement(cpd_cycle:) raise('expected an Effective::CpdCycle') unless cpd_cycle.class.respond_to?(:effective_cpd_cpd_cycle?) cpd_statement(cpd_cycle: cpd_cycle) || cpd_statements.build(cpd_cycle: cpd_cycle) end module ClassMethods def effective_cpd_user?; true; end end end
Version data entries
5 entries across 5 versions & 1 rubygems