Sha256: 946cbfd957db7fa4bedd4a2df70dbbf7ce7fb3cf301a1b452594464c43f5c313

Contents?: true

Size: 626 Bytes

Versions: 62

Compression:

Stored size: 626 Bytes

Contents

# frozen_string_literal: true

require 'active_support'

class LHS::Record

  module Last
    extend ActiveSupport::Concern

    module ClassMethods
      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

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

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
lhs-22.1.1.pre lib/lhs/concerns/record/last.rb
lhs-22.1.0 lib/lhs/concerns/record/last.rb
lhs-22.0.0 lib/lhs/concerns/record/last.rb
lhs-21.3.1 lib/lhs/concerns/record/last.rb
lhs-21.3.0 lib/lhs/concerns/record/last.rb
lhs-21.3.0.pre.autoauth.1 lib/lhs/concerns/record/last.rb
lhs-21.2.4 lib/lhs/concerns/record/last.rb
lhs-21.2.3 lib/lhs/concerns/record/last.rb
lhs-21.2.3.pre.preload.pre.providers.pre.too.1 lib/lhs/concerns/record/last.rb
lhs-21.2.2 lib/lhs/concerns/record/last.rb
lhs-21.2.1 lib/lhs/concerns/record/last.rb
lhs-21.2.0 lib/lhs/concerns/record/last.rb
lhs-21.1.4 lib/lhs/concerns/record/last.rb
lhs-21.1.3 lib/lhs/concerns/record/last.rb
lhs-21.1.2 lib/lhs/concerns/record/last.rb
lhs-21.1.2.pre.keyfix.2 lib/lhs/concerns/record/last.rb
lhs-21.1.2.pre.keyfix.1 lib/lhs/concerns/record/last.rb
lhs-21.1.2.pre.fix.pre.cant.pre.add.pre.new.pre.key.pre.during.pre.iteration.1 lib/lhs/concerns/record/last.rb
lhs-21.1.1.pre.pre.fix.pre.cant.pre.add.pre.new.pre.key.pre.during.pre.iteration.1 lib/lhs/concerns/record/last.rb
lhs-21.1.0 lib/lhs/concerns/record/last.rb