Class: TypeBalancer::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/type_balancer/configuration.rb

Overview

Configuration class to handle all balancing options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configuration

Returns a new instance of Configuration.



9
10
11
12
13
14
15
16
17
# File 'lib/type_balancer/configuration.rb', line 9

def initialize(options = {})
  @type_field = options.fetch(:type_field, :type)
  @type_order = options[:type_order]
  @strategy = options[:strategy]
  @window_size = options[:window_size]
  @batch_size = options[:batch_size]
  @types = options[:types]
  @strategy_options = extract_strategy_options(options)
end

Instance Attribute Details

#batch_sizeObject

Returns the value of attribute batch_size.



6
7
8
# File 'lib/type_balancer/configuration.rb', line 6

def batch_size
  @batch_size
end

#strategyObject

Returns the value of attribute strategy.



6
7
8
# File 'lib/type_balancer/configuration.rb', line 6

def strategy
  @strategy
end

#strategy_optionsObject (readonly)

Returns the value of attribute strategy_options.



7
8
9
# File 'lib/type_balancer/configuration.rb', line 7

def strategy_options
  @strategy_options
end

#type_fieldObject

Returns the value of attribute type_field.



6
7
8
# File 'lib/type_balancer/configuration.rb', line 6

def type_field
  @type_field
end

#type_orderObject

Returns the value of attribute type_order.



6
7
8
# File 'lib/type_balancer/configuration.rb', line 6

def type_order
  @type_order
end

#typesObject

Returns the value of attribute types.



6
7
8
# File 'lib/type_balancer/configuration.rb', line 6

def types
  @types
end

#window_sizeObject

Returns the value of attribute window_size.



6
7
8
# File 'lib/type_balancer/configuration.rb', line 6

def window_size
  @window_size
end

Instance Method Details

#merge_window_sizeObject



19
20
21
22
23
# File 'lib/type_balancer/configuration.rb', line 19

def merge_window_size
  return strategy_options unless window_size

  strategy_options.merge(window_size: window_size)
end