Module: LHS::Record::Last::ClassMethods

Defined in:
lib/lhs/concerns/record/last.rb

Instance Method Summary collapse

Instance Method Details

#last(options = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/lhs/concerns/record/last.rb', line 11

def last(options = nil)
  options = trace!(options)
  first_batch = find_by({}, options).parent
  if first_batch.paginated?
    pagination = first_batch._pagination
    find_by({ pagination_key => pagination.class.page_to_offset(pagination.last_page, pagination.limit) }, options)
  else
    first_batch.last
  end
end

#last!(options = nil) ⇒ Object



22
23
24
# File 'lib/lhs/concerns/record/last.rb', line 22

def last!(options = nil)
  find_by!({}, trace!(options))
end