Sha256: 12a6d11b433cc3dc625147b84cfad34b62926c8b9a73db9929fe77d98d2331c6

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

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 Integer
      # @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 Integer
      # @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
      #
      # @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

1 entries across 1 versions & 1 rubygems

Version Path
ashikawa-core-0.8.0 lib/ashikawa-core/key_options.rb