Module: Morpheus::Mixins::Finders::ClassMethods
- Defined in:
- lib/morpheus/mixins/finders.rb
Instance Method Summary collapse
- #all ⇒ Object
- #find(*args) ⇒ Object
- #first ⇒ Object
- #limit(amount) ⇒ Object
- #page(page_number) ⇒ Object
- #results_per_page ⇒ Object
- #results_per_page=(_results_per_page) ⇒ Object
- #scoped ⇒ Object
- #where(query_attributes) ⇒ Object
Instance Method Details
#all ⇒ Object
34 35 36 37 |
# File 'lib/morpheus/mixins/finders.rb', line 34 def all attributes = [UrlBuilder.find_all(self), nil, {}] get(*attributes) end |
#find(*args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/morpheus/mixins/finders.rb', line 11 def find(*args) = args. if args.length == 1 case args.first when Integer, String attributes = [UrlBuilder.find_one(self, args.first.to_i), nil, { :id => args.first.to_i }] get(*attributes) when Array attributes = UrlBuilder.find_some(self, args.first.sort).push({ :ids => args.first }) get(*attributes) else raise ArgumentError, "Unrecognized argument (#{args.first.inspect})." end else attributes = UrlBuilder.find_some(self, args.sort).push({ :ids => args }) get(*attributes) end end |
#first ⇒ Object
39 40 41 |
# File 'lib/morpheus/mixins/finders.rb', line 39 def first limit(1).first end |
#limit(amount) ⇒ Object
47 48 49 |
# File 'lib/morpheus/mixins/finders.rb', line 47 def limit(amount) Relation.new(self).limit(amount) end |
#page(page_number) ⇒ Object
51 52 53 |
# File 'lib/morpheus/mixins/finders.rb', line 51 def page(page_number) Relation.new(self).page(page_number) end |
#results_per_page ⇒ Object
55 56 57 |
# File 'lib/morpheus/mixins/finders.rb', line 55 def results_per_page @results_per_page || 10 end |
#results_per_page=(_results_per_page) ⇒ Object
59 60 61 |
# File 'lib/morpheus/mixins/finders.rb', line 59 def results_per_page=(_results_per_page) @results_per_page = _results_per_page end |