Sha256: 58654c9350eccdc8f9147ead5f3ff6ef2141091a5d9135acd36c08ba7ec26f7c

Contents?: true

Size: 626 Bytes

Versions: 12

Compression:

Stored size: 626 Bytes

Contents

# frozen_string_literal: true

require 'active_support'

class DHS::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

12 entries across 12 versions & 1 rubygems

Version Path
dhs-1.6.0 lib/dhs/concerns/record/last.rb
dhs-1.5.0 lib/dhs/concerns/record/last.rb
dhs-1.4.2 lib/dhs/concerns/record/last.rb
dhs-1.4.1 lib/dhs/concerns/record/last.rb
dhs-1.4.0 lib/dhs/concerns/record/last.rb
dhs-1.3.0 lib/dhs/concerns/record/last.rb
dhs-1.2.0 lib/dhs/concerns/record/last.rb
dhs-1.1.0 lib/dhs/concerns/record/last.rb
dhs-1.0.3 lib/dhs/concerns/record/last.rb
dhs-1.0.2 lib/dhs/concerns/record/last.rb
dhs-1.0.1 lib/dhs/concerns/record/last.rb
dhs-1.0.0 lib/dhs/concerns/record/last.rb