Module: SparkApi::Models::Finders
- Included in:
- Account, Activity, Contact, Defaultable, EmailLink, Idx, IdxLink, IncompleteListing, Listing, ListingCart, Message, Newsfeed, Portal, QuickSearch, SavedSearch, SharedLink, SharedListing, Sort, 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 18 |
# File 'lib/spark_api/models/finders.rb', line 7 def find(*arguments) scope = arguments.slice!(0) = arguments.slice!(0) || {} case scope when nil then raise ArgumentError, "Argument for find() can't be nil" 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
20 21 22 |
# File 'lib/spark_api/models/finders.rb', line 20 def find_one(*arguments) find(:one, *arguments) end |
#first(*arguments) ⇒ Object
24 25 26 |
# File 'lib/spark_api/models/finders.rb', line 24 def first(*arguments) find(:first, *arguments) end |
#last(*arguments) ⇒ Object
28 29 30 |
# File 'lib/spark_api/models/finders.rb', line 28 def last(*arguments) find(:last, *arguments) end |