Module: Notes

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
12
13
# File 'backend/app/model/mixins/notes.rb', line 7

def self.included(base)
  base.one_to_many :note

  Note.many_to_one base.table_name

  base.extend(ClassMethods)
end

Instance Method Details

#persistent_id_contextObject



22
23
24
25
26
27
28
29
30
31
32
# File 'backend/app/model/mixins/notes.rb', line 22

def persistent_id_context
  if self.respond_to?(:root_record_id) && self.root_record_id
    parent_id = self.root_record_id
    parent_type = self.class.root_record_type.to_s
  else
    parent_id = self.id
    parent_type = self.class.my_jsonmodel.record_type
  end

  [parent_id, parent_type]
end

#update_from_json(json, opts = {}, apply_nested_records = true) ⇒ Object



16
17
18
19
# File 'backend/app/model/mixins/notes.rb', line 16

def update_from_json(json, opts = {}, apply_nested_records = true)
  obj = super
  self.class.apply_notes(obj, json)
end