Class: SparkApi::Models::IdxLink
- Extended by:
- Finders
- Defined in:
- lib/spark_api/models/idx_link.rb
Constant Summary collapse
- LINK_TYPES =
["QuickSearch", "SavedSearch", "MyListings", "Roster"]
Constants included from Paginate
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- .default(options = {}) ⇒ Object
-
.find(*arguments) ⇒ Object
TODO Work all below into common base class.
- .find_single(scope, options) ⇒ Object
- .first(*arguments) ⇒ Object
- .last(*arguments) ⇒ Object
Methods included from Finders
Methods inherited from Base
#connection, connection, count, element_name, element_name=, get, #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
.default(options = {}) ⇒ Object
33 34 35 36 |
# File 'lib/spark_api/models/idx_link.rb', line 33 def self.default( = {}) response = connection.get("/#{self.element_name}/default", ).first response.nil? ? nil : new(response) end |
.find(*arguments) ⇒ Object
TODO Work all below into common base class
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/spark_api/models/idx_link.rb', line 12 def self.find(*arguments) scope = arguments.slice!(0) = arguments.slice!(0) || {} case scope when :all then find_every() when :first then find_every().first when :last then find_every().last when :one then find_one() else find_single(scope, ) end end |
.find_single(scope, options) ⇒ Object
40 41 42 43 |
# File 'lib/spark_api/models/idx_link.rb', line 40 def self.find_single(scope, ) resp = SparkApi.client.get("/idxlinks/#{scope}", ) new(resp.first) end |
.first(*arguments) ⇒ Object
25 26 27 |
# File 'lib/spark_api/models/idx_link.rb', line 25 def self.first(*arguments) find(:first, *arguments) end |
.last(*arguments) ⇒ Object
29 30 31 |
# File 'lib/spark_api/models/idx_link.rb', line 29 def self.last(*arguments) find(:last, *arguments) end |