Class: TestIds::Configuration

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

Defined Under Namespace

Classes: Item

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Configuration

Returns a new instance of Configuration.



90
91
92
93
# File 'lib/test_ids/configuration.rb', line 90

def initialize(id)
  @id = id
  @allocator = Allocator.new(self)
end

Instance Attribute Details

#allocatorObject (readonly)

Returns the value of attribute allocator.



88
89
90
# File 'lib/test_ids/configuration.rb', line 88

def allocator
  @allocator
end

Instance Method Details

#bins(options = {}, &block) ⇒ Object



99
100
101
102
103
104
105
# File 'lib/test_ids/configuration.rb', line 99

def bins(options = {}, &block)
  @bins ||= Item.new
  if block_given?
    @bins.callback(options, &block)
  end
  @bins
end

#bins=(val) ⇒ Object

An alias for config.bins.algorithm=



108
109
110
# File 'lib/test_ids/configuration.rb', line 108

def bins=(val)
  bins.algorithm = val
end

#empty?Boolean

Returns:

  • (Boolean)


161
162
163
# File 'lib/test_ids/configuration.rb', line 161

def empty?
  bins.empty? && softbins.empty? && numbers.empty?
end

#freezeObject



169
170
171
172
173
174
# File 'lib/test_ids/configuration.rb', line 169

def freeze
  bins.freeze
  softbins.freeze
  numbers.freeze
  super
end

#idObject



95
96
97
# File 'lib/test_ids/configuration.rb', line 95

def id
  @id
end

#load_from_serialized(store) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



185
186
187
188
189
# File 'lib/test_ids/configuration.rb', line 185

def load_from_serialized(store)
  bins.load_from_serialized(store['bins'])
  softbins.load_from_serialized(store['softbins'])
  numbers.load_from_serialized(store['numbers'])
end

#numbers(options = {}, &block) ⇒ Object



125
126
127
128
129
130
131
# File 'lib/test_ids/configuration.rb', line 125

def numbers(options = {}, &block)
  @numbers ||= Item.new
  if block_given?
    @numbers.callback(options, &block)
  end
  @numbers
end

#numbers=(val) ⇒ Object

An alias for config.numbers.algorithm=



134
135
136
# File 'lib/test_ids/configuration.rb', line 134

def numbers=(val)
  numbers.algorithm = val
end

#send_to_ate=(val) ⇒ Object



138
139
140
# File 'lib/test_ids/configuration.rb', line 138

def send_to_ate=(val)
  @send_to_ate = !!val
end

#send_to_ate?Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/test_ids/configuration.rb', line 142

def send_to_ate?
  defined?(@send_to_ate) ? @send_to_ate : true
end

#softbins(options = {}, &block) ⇒ Object



112
113
114
115
116
117
118
# File 'lib/test_ids/configuration.rb', line 112

def softbins(options = {}, &block)
  @softbins ||= Item.new
  if block_given?
    @softbins.callback(options, &block)
  end
  @softbins
end

#softbins=(val) ⇒ Object

An alias for config.softbins.algorithm=



121
122
123
# File 'lib/test_ids/configuration.rb', line 121

def softbins=(val)
  softbins.algorithm = val
end

#to_json(*a) ⇒ Object



176
177
178
179
180
181
182
# File 'lib/test_ids/configuration.rb', line 176

def to_json(*a)
  {
    'bins'     => bins,
    'softbins' => softbins,
    'numbers'  => numbers
  }.to_json(*a)
end

#unique_by_flow=(val) ⇒ Object



146
147
148
# File 'lib/test_ids/configuration.rb', line 146

def unique_by_flow=(val)
  @unique_by_flow = !!val
end

#unique_by_flow?Boolean

Returns:

  • (Boolean)


150
151
152
# File 'lib/test_ids/configuration.rb', line 150

def unique_by_flow?
  @unique_by_flow || false
end

#validate!Object



154
155
156
157
158
159
# File 'lib/test_ids/configuration.rb', line 154

def validate!
  unless validated?
    @validated = true
    freeze
  end
end

#validated?Boolean

Returns:

  • (Boolean)


165
166
167
# File 'lib/test_ids/configuration.rb', line 165

def validated?
  @validated
end