Module: TimestampAPI::ModelDefaultAPIMethods::ClassMethods
- Defined in:
- lib/timestamp_api/model_default_api_methods.rb
Instance Method Summary collapse
- #all(query_params = {}) ⇒ Object
- #api_path(path = nil) ⇒ Object
- #find(id, query_params = {}) ⇒ Object
Instance Method Details
#all(query_params = {}) ⇒ Object
17 18 19 20 |
# File 'lib/timestamp_api/model_default_api_methods.rb', line 17 def all(query_params = {}) raise APIPathNotSet.new(self) if api_path.nil? TimestampAPI.request(:get, api_path, query_params) end |
#api_path(path = nil) ⇒ Object
13 14 15 |
# File 'lib/timestamp_api/model_default_api_methods.rb', line 13 def api_path(path = nil) path.nil? ? self.class_variable_get(:@@api_path) : self.class_variable_set(:@@api_path, path) end |
#find(id, query_params = {}) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/timestamp_api/model_default_api_methods.rb', line 22 def find(id, query_params = {}) return nil if id.nil? raise APIPathNotSet.new(self) if api_path.nil? TimestampAPI.request(:get, "#{api_path}/#{id}", query_params) rescue RestClient::ResourceNotFound raise ResourceNotFound.new(self, id) end |