Module: SparkApi::Models::Finders
- Included in:
- Account, Activity, Contact, Listing, ListingCart, Portal, SavedSearch, SharedListing, StandardFields, VowAccount
- Defined in:
- lib/spark_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
- #find(*arguments) ⇒ Object
- #find_one(*arguments) ⇒ Object
- #first(*arguments) ⇒ Object
- #last(*arguments) ⇒ Object
Instance Method Details
#find(*arguments) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/spark_api/models/finders.rb', line 7 def 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_every(.merge(:_limit => 1)).first else find_single(scope, ) end end |
#find_one(*arguments) ⇒ Object
19 20 21 |
# File 'lib/spark_api/models/finders.rb', line 19 def find_one(*arguments) find(:one, *arguments) end |
#first(*arguments) ⇒ Object
23 24 25 |
# File 'lib/spark_api/models/finders.rb', line 23 def first(*arguments) find(:first, *arguments) end |
#last(*arguments) ⇒ Object
27 28 29 |
# File 'lib/spark_api/models/finders.rb', line 27 def last(*arguments) find(:last, *arguments) end |