Class: SparkApi::Models::Note
- Extended by:
- Subresource
- Defined in:
- lib/spark_api/models/note.rb
Constant Summary
Constants included from Paginate
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Subresource
build_subclass, find_by_id, find_by_listing_key, parse_date_start_and_end_times
Methods inherited from Base
#connection, connection, count, element_name, element_name=, first, #id, #initialize, #load, #method_missing, #parse_id, path, #path, #persisted?, prefix, prefix=, #resource_pluralized, #resource_uri, #respond_to?, #to_param, #to_partial_path
Methods included from Paginate
#collect, #paginate, #per_page
Methods included from Dirty
#changed, #changed?, #changed_attributes, #changes, #dirty_attributes, #previous_changes
Constructor Details
This class inherits a constructor from SparkApi::Models::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class SparkApi::Models::Base
Class Method Details
.get(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/spark_api/models/note.rb', line 7 def self.get(={}) ret = super() if ret.empty? return nil else return ret.first end end |
Instance Method Details
#delete(args = {}) ⇒ Object
35 36 37 |
# File 'lib/spark_api/models/note.rb', line 35 def delete(args={}) connection.delete(self.class.path, args) end |
#save(arguments = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/spark_api/models/note.rb', line 16 def save(arguments={}) begin return save!(arguments) rescue BadResourceRequest => e rescue NotFound => e # log and leave SparkApi.logger.error("Failed to save note #{self} (path: #{self.class.path}): #{e.}") end false end |
#save!(args = {}) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/spark_api/models/note.rb', line 27 def save!(args={}) args.merge(:Notes => attributes['Note']) results = connection.put(self.class.path, {:Note => attributes['Note']}, args) result = results.first attributes['ResourceUri'] = result['ResourceUri'] true end |