Class: RingioAPI::Note

Inherits:
Base
  • Object
show all
Defined in:
lib/ringioAPI/note.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find(note_id) ⇒ Object

override methods as a temporary solution of the JSON parsing bugs of Rails



6
7
8
# File 'lib/ringioAPI/note.rb', line 6

def self.find(note_id)
  super(note_id).note
end

Instance Method Details

#saveObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ringioAPI/note.rb', line 10

def save

  result = super

  # move the fields returned after an update response to their proper place in the root
  begin
    self.id = self.note.id
  rescue NoMethodError
  end
  begin
    self.contact_id = self.note.contact_id
  rescue NoMethodError
  end
  begin
    self.author_id = self.note.author_id
  rescue NoMethodError
  end
  begin
    self.body = self.note.body
  rescue NoMethodError
  end
  begin
    self.last_updated = self.note.last_updated
  rescue NoMethodError
  end
  begin
    self.date_created = self.note.last_updated
  rescue NoMethodError
  end

  # clean the unused nested resource
  begin
    self.note = nil
  rescue NoMethodError
  end

  result
end