Module: Assessments::LinkedRecord
- Defined in:
- backend/app/model/mixins/assessments.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
3 4 5 6 |
# File 'backend/app/model/mixins/assessments.rb', line 3 def self.included(base) base.define_relationship(:name => :assessment, :contains_references_to_types => proc {[Assessment]}) end |
Instance Method Details
#delete ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'backend/app/model/mixins/assessments.rb', line 8 def delete # only allow delete of the record if not linked to any assessments object_graph = self.object_graph assessment_rlshp = self.class.find_relationship(:assessment) if object_graph.models.any? {|model| model.is_relationship? && model == assessment_rlshp } raise ConflictException.new("linked_to_assessment") end super end |