Sha256: 9b929b8a3f94b040d2a21ff0ec2ae5a114e69a3b1f4433c3c0ac7198f32d113f

Contents?: true

Size: 737 Bytes

Versions: 16

Compression:

Stored size: 737 Bytes

Contents

# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/array
# frozen_string_literal: true

class Pagy
  # Add specialized backend methods to paginate array collections
  module Backend
    private

    # Return Pagy object and items
    def pagy_array(array, vars={})
      pagy = Pagy.new(pagy_array_get_vars(array, vars))
      [ pagy, array[pagy.offset, pagy.items] ]
    end

    # Sub-method called only by #pagy_array: here for easy customization of variables by overriding
    def pagy_array_get_vars(array, vars)
      pagy_set_items_from_params(vars) if defined?(UseItemsExtra)
      vars[:count] ||= array.size
      vars[:page]  ||= params[ vars[:page_param] || VARS[:page_param] ]
      vars
    end

  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/pagy-4.11.0/lib/pagy/extras/array.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/pagy-4.11.0/lib/pagy/extras/array.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/pagy-4.11.0/lib/pagy/extras/array.rb
pagy-4.11.0 lib/pagy/extras/array.rb
pagy-4.10.2 lib/pagy/extras/array.rb
pagy-4.10.1 lib/pagy/extras/array.rb
pagy-4.10.0 lib/pagy/extras/array.rb
pagy-4.9.0 lib/pagy/extras/array.rb
pagy-4.8.1 lib/pagy/extras/array.rb
pagy-4.8.0 lib/pagy/extras/array.rb
pagy-4.7.1 lib/pagy/extras/array.rb
pagy-4.7.0 lib/pagy/extras/array.rb
pagy-4.6.0 lib/pagy/extras/array.rb
pagy-4.5.1 lib/pagy/extras/array.rb
pagy-4.5.0 lib/pagy/extras/array.rb
pagy-4.4.0 lib/pagy/extras/array.rb