Class: Ketchup::Note
- Inherits:
-
Object
- Object
- Ketchup::Note
- Defined in:
- lib/ketchup/note.rb
Overview
Represents a note for list/agenda item in a meeting. Only the content is editable.
If you want to change the order of notes, you can do that using Ketchup::NoteArray (the item’s note array).
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#content ⇒ Object
Returns the value of attribute content.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#item ⇒ Object
readonly
Returns the value of attribute item.
-
#item_id ⇒ Object
readonly
Returns the value of attribute item_id.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#shortcode_url ⇒ Object
readonly
Returns the value of attribute shortcode_url.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
-
#destroy ⇒ Object
Deletes the note from the server.
-
#initialize(api, item, params = {}) ⇒ Note
constructor
Create a new note for a given item, using an existing api connection.
-
#new_record? ⇒ Boolean
Indicates whether the note exists on the server yet.
-
#save ⇒ Object
Saves the note to the server, whether it’s a new note or an existing one.
Constructor Details
#initialize(api, item, params = {}) ⇒ Note
Create a new note for a given item, using an existing api connection. You generally won’t want to call this yourself - the better interface to create new notes is via a item’s note array.
However, if you are doing some internal hacking, it’s worth noting that all keys for parameters in the hash should be strings, not symbols.
28 29 30 31 32 33 |
# File 'lib/ketchup/note.rb', line 28 def initialize(api, item, params = {}) @api = api @item = item overwrite params end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
8 9 10 |
# File 'lib/ketchup/note.rb', line 8 def api @api end |
#content ⇒ Object
Returns the value of attribute content.
10 11 12 |
# File 'lib/ketchup/note.rb', line 10 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
8 9 10 |
# File 'lib/ketchup/note.rb', line 8 def created_at @created_at end |
#item ⇒ Object (readonly)
Returns the value of attribute item.
8 9 10 |
# File 'lib/ketchup/note.rb', line 8 def item @item end |
#item_id ⇒ Object (readonly)
Returns the value of attribute item_id.
8 9 10 |
# File 'lib/ketchup/note.rb', line 8 def item_id @item_id end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
8 9 10 |
# File 'lib/ketchup/note.rb', line 8 def position @position end |
#shortcode_url ⇒ Object (readonly)
Returns the value of attribute shortcode_url.
8 9 10 |
# File 'lib/ketchup/note.rb', line 8 def shortcode_url @shortcode_url end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
8 9 10 |
# File 'lib/ketchup/note.rb', line 8 def updated_at @updated_at end |
Instance Method Details
#destroy ⇒ Object
Deletes the note from the server. If the note has never been saved, this method will do nothing at all.
57 58 59 60 61 |
# File 'lib/ketchup/note.rb', line 57 def destroy return if new_record? @api.delete "/notes/#{shortcode_url}.json" end |
#new_record? ⇒ Boolean
Indicates whether the note exists on the server yet.
39 40 41 |
# File 'lib/ketchup/note.rb', line 39 def new_record? shortcode_url.nil? end |
#save ⇒ Object
Saves the note to the server, whether it’s a new note or an existing one.
45 46 47 48 49 50 51 52 |
# File 'lib/ketchup/note.rb', line 45 def save if new_record? overwrite @api.post("/items/#{item.shortcode_url}/notes.json", 'content' => content) else overwrite @api.put("/notes/#{shortcode_url}.json", 'content' => content) end end |