Sha256: cec54389b8e29385542d418c88ba7105aafc079363d875be37e679a7d08ba915

Contents?: true

Size: 1.73 KB

Versions: 5

Compression:

Stored size: 1.73 KB

Contents

# -*- encoding : utf-8 -*-
module Ashikawa
  module Core
    # Options for controlling keys of a collection
    class KeyOptions
      # Either traditional or autoincrement
      #
      # @return Symbol
      # @api public
      # @example Get the type of the KeyOptions
      #   keyOptions = KeyOptions.new({ :type => :autoincrement })
      #   keyOptions.type # => :autoincrement
      attr_reader :type

      # A specific start value
      #
      # @return Fixnum
      # @api public
      # @example Get the type of the KeyOptions
      #   keyOptions = KeyOptions.new({ :offset => 12 })
      #   keyOptions.offset # => 12
      attr_reader :offset

      # Size of increment steps
      #
      # @return Fixnum
      # @api public
      # @example Get the type of the KeyOptions
      #   keyOptions = KeyOptions.new({ :increment => 12 })
      #   keyOptions.increment # => 12
      attr_reader :increment

      # Is the user allowed to set keys by him- or herself?
      #
      # @return Boolean
      # @api public
      # @example Get the type of the KeyOptions
      #   keyOptions = KeyOptions.new({ :allowUserKeys => true })
      #   keyOptions.allow_user_keys # => true
      attr_reader :allow_user_keys

      # Create a new KeyOptions object from the raw key options
      #
      # @param [Hash] raw_key_options The raw options for the key returned from the server
      # @api public
      # @example Create a new KeyOptions object
      #   KeyOptions.new({ :type => :autoincrement })
      def initialize(raw_key_options)
        @type = raw_key_options['type']
        @offset = raw_key_options['offset']
        @increment = raw_key_options['increment']
        @allow_user_keys = raw_key_options['allowUserKeys']
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ashikawa-core-0.14.0 lib/ashikawa-core/key_options.rb
ashikawa-core-0.13.1 lib/ashikawa-core/key_options.rb
ashikawa-core-0.13.0 lib/ashikawa-core/key_options.rb
ashikawa-core-0.12.0 lib/ashikawa-core/key_options.rb
ashikawa-core-0.11.0 lib/ashikawa-core/key_options.rb