Class: Ketchup::Item
- Inherits:
-
Object
- Object
- Ketchup::Item
- Defined in:
- lib/ketchup/item.rb
Overview
Represents a list/agenda item in a meeting. Only the content is editable.
If you want to change the order of items, you can do that using Ketchup::ItemArray (the meeting’s item 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.
-
#meeting ⇒ Object
readonly
Returns the value of attribute meeting.
-
#meeting_id ⇒ Object
readonly
Returns the value of attribute meeting_id.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#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 item from the server.
-
#initialize(api, meeting, params = {}) ⇒ Item
constructor
Create a new item for a given meeting, using an existing api connection.
-
#new_record? ⇒ Boolean
Indicates whether the item exists on the server yet.
-
#save ⇒ Object
Saves the item to the server, whether it’s a new item or an existing one.
Constructor Details
#initialize(api, meeting, params = {}) ⇒ Item
Create a new item for a given meeting, using an existing api connection. You generally won’t want to call this yourself - the better interface to create new items is via a meeting’s item 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.
27 28 29 30 31 32 33 34 |
# File 'lib/ketchup/item.rb', line 27 def initialize(api, meeting, params = {}) @api = api @meeting = meeting overwrite params @notes = Ketchup::NoteArray.new @api, self, (params['notes'] || []) end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
7 8 9 |
# File 'lib/ketchup/item.rb', line 7 def api @api end |
#content ⇒ Object
Returns the value of attribute content.
9 10 11 |
# File 'lib/ketchup/item.rb', line 9 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
7 8 9 |
# File 'lib/ketchup/item.rb', line 7 def created_at @created_at end |
#meeting ⇒ Object (readonly)
Returns the value of attribute meeting.
7 8 9 |
# File 'lib/ketchup/item.rb', line 7 def meeting @meeting end |
#meeting_id ⇒ Object (readonly)
Returns the value of attribute meeting_id.
7 8 9 |
# File 'lib/ketchup/item.rb', line 7 def meeting_id @meeting_id end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
7 8 9 |
# File 'lib/ketchup/item.rb', line 7 def notes @notes end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
7 8 9 |
# File 'lib/ketchup/item.rb', line 7 def position @position end |
#shortcode_url ⇒ Object (readonly)
Returns the value of attribute shortcode_url.
7 8 9 |
# File 'lib/ketchup/item.rb', line 7 def shortcode_url @shortcode_url end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
7 8 9 |
# File 'lib/ketchup/item.rb', line 7 def updated_at @updated_at end |
Instance Method Details
#destroy ⇒ Object
Deletes the item from the server. If the item has never been saved, this method will do nothing at all.
59 60 61 62 63 |
# File 'lib/ketchup/item.rb', line 59 def destroy return if new_record? @api.delete "/items/#{shortcode_url}.json" end |
#new_record? ⇒ Boolean
Indicates whether the item exists on the server yet.
40 41 42 |
# File 'lib/ketchup/item.rb', line 40 def new_record? shortcode_url.nil? end |
#save ⇒ Object
Saves the item to the server, whether it’s a new item or an existing one. This does not save underlying notes.
47 48 49 50 51 52 53 54 |
# File 'lib/ketchup/item.rb', line 47 def save if new_record? overwrite @api.post("/meetings/#{meeting.shortcode_url}/items.json", 'content' => content) else overwrite @api.put("/items/#{shortcode_url}.json", 'content' => content) end end |