Module: AgentNames
- Defined in:
- backend/app/model/mixins/agent_names.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#before_validation ⇒ Object
-
#update_from_json(json, opts = {}, apply_nested_records = true) ⇒ Object
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'backend/app/model/mixins/agent_names.rb', line 3 def self.included(base) base.set_model_scope :global base.one_to_many :structured_date_label, :class => "StructuredDateLabel" base.def_nested_record(:the_property => :use_dates, :contains_records_of_type => :structured_date_label, :corresponding_to_association => :structured_date_label) base.one_to_one :name_authority_id base.extend(ClassMethods) end |
Instance Method Details
#before_validation ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'backend/app/model/mixins/agent_names.rb', line 19 def before_validation super # force to NULL (not 0) to make sure uniqueness constraints work as # desired. self. = nil if self. != 1 self.is_display_name = nil if self.is_display_name != 1 end |
#update_from_json(json, opts = {}, apply_nested_records = true) ⇒ Object
29 30 31 32 |
# File 'backend/app/model/mixins/agent_names.rb', line 29 def update_from_json(json, opts = {}, apply_nested_records = true) obj = super self.class.(obj, json) end |