Class: Tarantool::Rails::Configuration

Inherits:
Data
  • Object
show all
Defined in:
tarantool-rails/lib/tarantool/rails/configuration.rb,
tarantool-rails/lib/tarantool/rails/configuration.rb

Overview

Builds a Configuration from the Hash config_for returns.

Constant Summary collapse

CLIENT_KEYS =
%i[user password connect_timeout request_timeout reconnect reconnect_attempts reconnect_delay
reconnect_max_delay max_frame_size].freeze
KEYS =
(CLIENT_KEYS + %i[addresses address read write storage crud admin_uri]).freeze
CRUD_KEYS =
%i[primary_index read write timeout_margin].freeze
STORAGES =
%i[box crud].freeze
URI_PASSWORD =
%r{:[^:@/]*@}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#addresses ⇒ Object (readonly)

Returns the value of attribute addresses

Returns:

  • (Object) —

    the current value of addresses



7
8
9
# File 'tarantool-rails/lib/tarantool/rails/configuration.rb', line 7

def addresses
  @addresses
end

#admin_uri ⇒ Object (readonly)

Returns the value of attribute admin_uri

Returns:

  • (Object) —

    the current value of admin_uri



7
8
9
# File 'tarantool-rails/lib/tarantool/rails/configuration.rb', line 7

def admin_uri
  @admin_uri
end

#client_options ⇒ Object (readonly)

Returns the value of attribute client_options

Returns:

  • (Object) —

    the current value of client_options



7
8
9
# File 'tarantool-rails/lib/tarantool/rails/configuration.rb', line 7

def client_options
  @client_options
end

#crud ⇒ Object (readonly)

Returns the value of attribute crud

Returns:

  • (Object) —

    the current value of crud



7
8
9
# File 'tarantool-rails/lib/tarantool/rails/configuration.rb', line 7

def crud
  @crud
end

#read ⇒ Object (readonly)

Returns the value of attribute read

Returns:

  • (Object) —

    the current value of read



7
8
9
# File 'tarantool-rails/lib/tarantool/rails/configuration.rb', line 7

def read
  @read
end

#storage ⇒ Object (readonly)

Returns the value of attribute storage

Returns:

  • (Object) —

    the current value of storage



7
8
9
# File 'tarantool-rails/lib/tarantool/rails/configuration.rb', line 7

def storage
  @storage
end

#write ⇒ Object (readonly)

Returns the value of attribute write

Returns:

  • (Object) —

    the current value of write



7
8
9
# File 'tarantool-rails/lib/tarantool/rails/configuration.rb', line 7

def write
  @write
end

Class Method Details

.from_hash(hash) ⇒ Object



36
37
38
39
40
41
42
# File 'tarantool-rails/lib/tarantool/rails/configuration.rb', line 36

def from_hash(hash)
  hash = checked(hash.to_h.transform_keys(&:to_sym))

  new(addresses: addresses(hash), client_options: hash.slice(*CLIENT_KEYS), storage: storage(hash[:storage]),
      read: options(hash[:read]), write: options(hash[:write]), crud: crud(hash[:crud]),
      admin_uri: hash[:admin_uri])
end

Instance Method Details

#inspect ⇒ Object Also known as: to_s



8
9
10
11
12
# File 'tarantool-rails/lib/tarantool/rails/configuration.rb', line 8

def inspect
  fields = to_h.map { |key, value| "#{key}=#{filtered(key, value).inspect}" }.join(', ')

  "#<data #{self.class.name} #{fields}>"
end