Sha256: 35cb33863e1821942427223f2dbb38a9fa72950f13096b98f67260658dc37b88

Contents?: true

Size: 688 Bytes

Versions: 3

Compression:

Stored size: 688 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) || :items
      end

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

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

      def offset_key
        @configuration.try(:[], :offset) || :offset
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lhs-3.4.2 lib/lhs/concerns/record/configuration.rb
lhs-3.4.1 lib/lhs/concerns/record/configuration.rb
lhs-3.4.0 lib/lhs/concerns/record/configuration.rb