Module: FlexmlsApi::Models::Finders

Included in:
Account, Contact, Listing, ListingCart, SavedSearch, SharedListing, StandardFields
Defined in:
lib/flexmls_api/models/finders.rb

Overview

Rails-like finders module

Adds the base set of finder class methods to the models that support them (not all of them do)

Instance Method Summary collapse

Instance Method Details

#find(*arguments) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/flexmls_api/models/finders.rb', line 7

def 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

#first(*arguments) ⇒ Object



19
20
21
# File 'lib/flexmls_api/models/finders.rb', line 19

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

#last(*arguments) ⇒ Object



23
24
25
# File 'lib/flexmls_api/models/finders.rb', line 23

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