Module: NullRecord::FinderMethods::ClassMethods
- Defined in:
- lib/null_record/finder_methods.rb
Instance Method Summary collapse
- #fifth ⇒ Object
- #find(id) ⇒ Object
- #find_by(attributes) ⇒ Object
- #first ⇒ Object
- #forty_two ⇒ Object
- #fourth ⇒ Object
- #last ⇒ Object
- #second ⇒ Object
- #take(limit = nil) ⇒ Object
- #third ⇒ Object
Instance Method Details
#fifth ⇒ Object
6 7 8 |
# File 'lib/null_record/finder_methods.rb', line 6 def fifth super || null_object end |
#find(id) ⇒ Object
10 11 12 13 14 |
# File 'lib/null_record/finder_methods.rb', line 10 def find(id) super(id) rescue ActiveRecord::RecordNotFound null_object end |
#find_by(attributes) ⇒ Object
16 17 18 |
# File 'lib/null_record/finder_methods.rb', line 16 def find_by(attributes) super(attributes) || null_object end |
#first ⇒ Object
20 21 22 |
# File 'lib/null_record/finder_methods.rb', line 20 def first super || null_object end |
#forty_two ⇒ Object
24 25 26 |
# File 'lib/null_record/finder_methods.rb', line 24 def forty_two super || null_object end |
#fourth ⇒ Object
28 29 30 |
# File 'lib/null_record/finder_methods.rb', line 28 def fourth super || null_object end |
#last ⇒ Object
32 33 34 |
# File 'lib/null_record/finder_methods.rb', line 32 def last super || null_object end |
#second ⇒ Object
36 37 38 |
# File 'lib/null_record/finder_methods.rb', line 36 def second super || null_object end |
#take(limit = nil) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/null_record/finder_methods.rb', line 40 def take(limit = nil) if limit && limit > 1 result = super(limit) result.size > 1 ? result : Array.new(limit) { null_object } else super(limit) || null_object end end |
#third ⇒ Object
49 50 51 |
# File 'lib/null_record/finder_methods.rb', line 49 def third super || null_object end |