Module: ActiveRepository::Finders
- Included in:
- Base
- Defined in:
- lib/active_repository/finders.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#find(id) ⇒ Object
Searches for an object containing the id in #id.
-
#first ⇒ Object
Returns first persisted object.
-
#last ⇒ Object
Returns last persisted object.
Instance Method Details
#find(id) ⇒ Object
Searches for an object containing the id in #id
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/active_repository/finders.rb', line 5 def find(id) begin if repository? super(id) else serialize!(PersistenceAdapter.find(self, id)) end rescue Exception => e = "Couldn't find #{self} with ID=#{id}" = "Couldn't find all #{self} objects with IDs (#{id.join(', ')})" if id.is_a?(Array) raise ActiveHash::RecordNotFound.new() end end |
#first ⇒ Object
Returns first persisted object
21 22 23 |
# File 'lib/active_repository/finders.rb', line 21 def first repository? ? super : get(:first) end |
#last ⇒ Object
Returns last persisted object
26 27 28 |
# File 'lib/active_repository/finders.rb', line 26 def last repository? ? super : get(:last) end |