Sha256: 088e611933d239358a8532f69f6519642329c81fe4ba314a01c4f6bf830dda06

Contents?: true

Size: 553 Bytes

Versions: 13

Compression:

Stored size: 553 Bytes

Contents

require 'active_support'

class LHS::Record

  module Last
    extend ActiveSupport::Concern

    module ClassMethods
      def last(options = nil)
        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

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
lhs-16.1.5 lib/lhs/concerns/record/last.rb
lhs-16.1.4 lib/lhs/concerns/record/last.rb
lhs-16.1.3 lib/lhs/concerns/record/last.rb
lhs-16.1.2 lib/lhs/concerns/record/last.rb
lhs-16.1.1 lib/lhs/concerns/record/last.rb
lhs-16.1.0 lib/lhs/concerns/record/last.rb
lhs-16.0.1 lib/lhs/concerns/record/last.rb
lhs-16.0.0 lib/lhs/concerns/record/last.rb
lhs-15.7.0 lib/lhs/concerns/record/last.rb
lhs-15.6.1 lib/lhs/concerns/record/last.rb
lhs-15.6.0 lib/lhs/concerns/record/last.rb
lhs-15.5.1 lib/lhs/concerns/record/last.rb
lhs-15.5.0 lib/lhs/concerns/record/last.rb