Class: SparkApi::Models::IdxLink

Inherits:
Base
  • Object
show all
Defined in:
lib/spark_api/models/idx_link.rb

Constant Summary collapse

["QuickSearch", "SavedSearch", "MyListings", "Roster"]

Constants included from Paginate

Paginate::DEFAULT_PAGE_SIZE

Instance Attribute Summary

Attributes inherited from Base

#attributes, #errors, #parent

Class Method Summary collapse

Methods inherited from Base

#connection, connection, count, element_name, element_name=, get, #initialize, #load, #method_missing, #parse_id, #path, path, #persisted?, prefix, prefix=, #resource_uri, #respond_to?

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



30
31
32
33
# File 'lib/spark_api/models/idx_link.rb', line 30

def self.default(options = {})
  response = connection.get("/#{self.element_name}/default", options).first
  response.nil? ? nil : new(response)
end

.find(*arguments) ⇒ Object

TODO Work all below into common base class



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/spark_api/models/idx_link.rb', line 9

def self.find(*arguments)
  scope = arguments.slice!(0)
  options = arguments.slice!(0) || {}
  
  case scope
    when :all   then find_every(options)
    when :first then find_every(options).first
    when :last  then find_every(options).last
    when :one   then find_one(options)
    else             find_single(scope, options)
  end
end

.find_every(options) ⇒ Object

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/spark_api/models/idx_link.rb', line 37

def self.find_every(options)
  raise NotImplementedError # TODO
end

.find_one(options) ⇒ Object

Raises:

  • (NotImplementedError)


41
42
43
# File 'lib/spark_api/models/idx_link.rb', line 41

def self.find_one(options)
  raise NotImplementedError # TODO
end

.find_single(scope, options) ⇒ Object



45
46
47
48
# File 'lib/spark_api/models/idx_link.rb', line 45

def self.find_single(scope, options)
  resp = SparkApi.client.get("/idxlinks/#{scope}", options)
  new(resp.first)
end

.first(*arguments) ⇒ Object



22
23
24
# File 'lib/spark_api/models/idx_link.rb', line 22

def self.first(*arguments)
  find(:first, *arguments)
end

.last(*arguments) ⇒ Object



26
27
28
# File 'lib/spark_api/models/idx_link.rb', line 26

def self.last(*arguments)
  find(:last, *arguments)
end