Class: Ashikawa::Core::KeyOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/ashikawa-core/key_options.rb

Overview

Options for controlling keys of a collection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_key_options) ⇒ KeyOptions

Create a new KeyOptions object from the raw key options

Examples:

Create a new KeyOptions object

KeyOptions.new({ :type => :autoincrement })

Parameters:

  • raw_key_options (Hash)

    The raw options for the key returned from the server


48
49
50
51
52
53
# File 'lib/ashikawa-core/key_options.rb', line 48

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

Instance Attribute Details

#allow_user_keysObject (readonly)

Is the user allowed to set keys by him- or herself?

Examples:

Get the type of the KeyOptions

keyOptions = KeyOptions.new({ :allowUserKeys => true })
keyOptions.allow_user_keys # => true

Returns:

  • Boolean


40
41
42
# File 'lib/ashikawa-core/key_options.rb', line 40

def allow_user_keys
  @allow_user_keys
end

#incrementObject (readonly)

Size of increment steps

Examples:

Get the type of the KeyOptions

keyOptions = KeyOptions.new({ :increment => 12 })
keyOptions.increment # => 12

Returns:

  • Fixnum


31
32
33
# File 'lib/ashikawa-core/key_options.rb', line 31

def increment
  @increment
end

#offsetObject (readonly)

A specific start value

Examples:

Get the type of the KeyOptions

keyOptions = KeyOptions.new({ :offset => 12 })
keyOptions.offset # => 12

Returns:

  • Fixnum


22
23
24
# File 'lib/ashikawa-core/key_options.rb', line 22

def offset
  @offset
end

#typeObject (readonly)

Either traditional or autoincrement

Examples:

Get the type of the KeyOptions

keyOptions = KeyOptions.new({ :type => :autoincrement })
keyOptions.type # => :autoincrement

Returns:

  • Symbol


13
14
15
# File 'lib/ashikawa-core/key_options.rb', line 13

def type
  @type
end