Sha256: 3ea66a6d39f0aa6a7f3e87c366dd7bcb56adb1953bebc88d2dcf36b98c92eb7e

Contents?: true

Size: 974 Bytes

Versions: 64

Compression:

Stored size: 974 Bytes

Contents

require 'active_support'

class LHS::Record

  # Allows configuring endpoints
  # like which keys are used for the items, offset, total etc.
  module Configuration
    extend ActiveSupport::Concern

    mattr_accessor :configuration

    module ClassMethods
      def configuration(args)
        @configuration = args.freeze || {}
      end

      def items_key
        (@configuration.try(:[], :items_key) || :items).to_sym
      end

      def limit_key
        (@configuration.try(:[], :limit_key) || :limit).to_sym
      end

      def total_key
        (@configuration.try(:[], :total_key) || :total).to_sym
      end

      # Key used for determine current page
      def pagination_key
        (@configuration.try(:[], :pagination_key) || :offset).to_sym
      end

      # Strategy used for calculationg next pages and navigate pages
      def pagination_strategy
        (@configuration.try(:[], :pagination_strategy) || :offset).to_sym
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
lhs-11.0.1 lib/lhs/concerns/record/configuration.rb
lhs-11.0.0 lib/lhs/concerns/record/configuration.rb
lhs-10.1.1 lib/lhs/concerns/record/configuration.rb
lhs-10.1.0 lib/lhs/concerns/record/configuration.rb
lhs-10.0.0 lib/lhs/concerns/record/configuration.rb
lhs-9.1.1 lib/lhs/concerns/record/configuration.rb
lhs-9.1.0 lib/lhs/concerns/record/configuration.rb
lhs-9.0.4 lib/lhs/concerns/record/configuration.rb
lhs-9.0.3 lib/lhs/concerns/record/configuration.rb
lhs-9.0.2 lib/lhs/concerns/record/configuration.rb
lhs-9.0.1 lib/lhs/concerns/record/configuration.rb
lhs-9.0.0 lib/lhs/concerns/record/configuration.rb
lhs-8.0.0 lib/lhs/concerns/record/configuration.rb
lhs-7.4.1 lib/lhs/concerns/record/configuration.rb
lhs-7.4.0 lib/lhs/concerns/record/configuration.rb
lhs-7.3.0 lib/lhs/concerns/record/configuration.rb
lhs-7.2.5 lib/lhs/concerns/record/configuration.rb
lhs-7.2.4 lib/lhs/concerns/record/configuration.rb
lhs-7.2.3 lib/lhs/concerns/record/configuration.rb
lhs-7.2.2 lib/lhs/concerns/record/configuration.rb