Module: Assessments::LinkedAgent
- Defined in:
- backend/app/model/mixins/assessments.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
24 25 26 27 28 29 |
# File 'backend/app/model/mixins/assessments.rb', line 24 def self.included(base) base.define_relationship(:name => :surveyed_by, :contains_references_to_types => proc {[Assessment]}) base.define_relationship(:name => :assessment_reviewer, :contains_references_to_types => proc {[Assessment]}) end |
Instance Method Details
#delete ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'backend/app/model/mixins/assessments.rb', line 31 def delete # only allow delete of the agent if not linked to any assessments object_graph = self.object_graph assessment_rlshps = [self.class.find_relationship(:surveyed_by), self.class.find_relationship(:assessment_reviewer)] if object_graph.models.any? {|model| model.is_relationship? && assessment_rlshps.include?(model) } raise ConflictException.new("linked_to_assessment") end super end |