Module: Shared::AttributeAnnotations
- Extended by:
- ActiveSupport::Concern
- Included in:
- AlternateValue, Note, Tag
- Defined in:
- app/models/concerns/shared/attribute_annotations.rb
Overview
Shared code for polymorphics that reference specific attributes
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #annotated_column ⇒ String
- #annotated_value_is_not_identical_to_attribute ⇒ Object protected
- #annotation_value ⇒ Object
-
#attribute_to_annotate_is_valid_for_object ⇒ Object
protected
Tests presence of original value AND legality of attribute being annotated.
- #original_value ⇒ Object
Instance Method Details
#annotated_column ⇒ String
17 18 19 |
# File 'app/models/concerns/shared/attribute_annotations.rb', line 17 def annotated_column self.send(self.class.annotated_attribute_column) end |
#annotated_value_is_not_identical_to_attribute ⇒ Object (protected)
40 41 42 |
# File 'app/models/concerns/shared/attribute_annotations.rb', line 40 def annotated_value_is_not_identical_to_attribute errors.add(self.class.annotated_attribute_column, 'contains annotation identical to existing attribute') if annotation_value == original_value end |
#annotation_value ⇒ Object
21 22 23 |
# File 'app/models/concerns/shared/attribute_annotations.rb', line 21 def annotation_value self.send(self.class.annotation_value_column) end |
#attribute_to_annotate_is_valid_for_object ⇒ Object (protected)
Tests presence of original value AND legality of attribute being annotated
32 33 34 35 36 37 38 |
# File 'app/models/concerns/shared/attribute_annotations.rb', line 32 def attribute_to_annotate_is_valid_for_object if annotated_object if !ApplicationEnumeration.annotatable_attributes(annotated_object).include?(annotated_column.to_sym) errors.add(self.class.annotated_attribute_column, "#{annotated_column} is not annotatable, it may be empty or non-annotatable") end end end |
#original_value ⇒ Object
25 26 27 |
# File 'app/models/concerns/shared/attribute_annotations.rb', line 25 def original_value annotated_object.send(annotated_column) if annotated_object.respond_to?(annotated_column) end |