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.



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

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

Instance Attribute Details

#allocatorObject (readonly)

Returns the value of attribute allocator.



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

def allocator
  @allocator
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

Instance Method Details

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



96
97
98
99
100
# File 'lib/test_ids/configuration.rb', line 96

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

#bins=(val) ⇒ Object

An alias for config.bins.algorithm=



103
104
105
# File 'lib/test_ids/configuration.rb', line 103

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

#empty?Boolean

Returns:

  • (Boolean)


152
153
154
# File 'lib/test_ids/configuration.rb', line 152

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

#freezeObject



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

def freeze
  bins.freeze
  softbins.freeze
  numbers.freeze
  super
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.



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

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



118
119
120
121
122
# File 'lib/test_ids/configuration.rb', line 118

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

#numbers=(val) ⇒ Object

An alias for config.numbers.algorithm=



125
126
127
# File 'lib/test_ids/configuration.rb', line 125

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

#send_to_ate=(val) ⇒ Object



129
130
131
# File 'lib/test_ids/configuration.rb', line 129

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

#send_to_ate?Boolean

Returns:

  • (Boolean)


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

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

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



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

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

#softbins=(val) ⇒ Object

An alias for config.softbins.algorithm=



114
115
116
# File 'lib/test_ids/configuration.rb', line 114

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

#to_json(*a) ⇒ Object



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

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

#unique_by_flow=(val) ⇒ Object



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

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

#unique_by_flow?Boolean

Returns:

  • (Boolean)


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

def unique_by_flow?
  @unique_by_flow || false
end

#validate!Object



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

def validate!
  return if validated?

  @validated = true
  freeze
end

#validated?Boolean

Returns:

  • (Boolean)


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

def validated?
  @validated
end