Class: TestIds::Configuration
- Inherits:
-
Object
- Object
- TestIds::Configuration
- Defined in:
- lib/test_ids/configuration.rb
Defined Under Namespace
Classes: Item
Instance Attribute Summary collapse
-
#allocator ⇒ Object
readonly
Returns the value of attribute allocator.
Instance Method Summary collapse
- #bins(&block) ⇒ Object
- #empty? ⇒ Boolean
- #freeze ⇒ Object
- #id ⇒ Object
-
#initialize(id) ⇒ Configuration
constructor
A new instance of Configuration.
- #load_from_serialized(store) ⇒ Object private
- #numbers(&block) ⇒ Object
-
#numbers=(val) ⇒ Object
An alias for config.numbers.algorithm=.
- #send_to_ate ⇒ Object
- #send_to_ate=(val) ⇒ Object
- #softbins(&block) ⇒ Object
-
#softbins=(val) ⇒ Object
An alias for config.softbins.algorithm=.
- #to_json(*a) ⇒ Object
- #validate! ⇒ Object
- #validated? ⇒ Boolean
Constructor Details
#initialize(id) ⇒ Configuration
Returns a new instance of Configuration.
82 83 84 85 |
# File 'lib/test_ids/configuration.rb', line 82 def initialize(id) @id = id @allocator = Allocator.new(self) end |
Instance Attribute Details
#allocator ⇒ Object (readonly)
Returns the value of attribute allocator.
80 81 82 |
# File 'lib/test_ids/configuration.rb', line 80 def allocator @allocator end |
Instance Method Details
#bins(&block) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/test_ids/configuration.rb', line 91 def bins(&block) @bins ||= Item.new if block_given? @bins.callback(&block) end @bins end |
#empty? ⇒ Boolean
143 144 145 |
# File 'lib/test_ids/configuration.rb', line 143 def empty? bins.empty? && softbins.empty? && numbers.empty? end |
#freeze ⇒ Object
151 152 153 154 155 156 |
# File 'lib/test_ids/configuration.rb', line 151 def freeze bins.freeze softbins.freeze numbers.freeze super end |
#id ⇒ Object
87 88 89 |
# File 'lib/test_ids/configuration.rb', line 87 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.
167 168 169 170 171 |
# File 'lib/test_ids/configuration.rb', line 167 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(&block) ⇒ Object
112 113 114 115 116 117 118 |
# File 'lib/test_ids/configuration.rb', line 112 def numbers(&block) @numbers ||= Item.new if block_given? @numbers.callback(&block) end @numbers end |
#numbers=(val) ⇒ Object
An alias for config.numbers.algorithm=
121 122 123 |
# File 'lib/test_ids/configuration.rb', line 121 def numbers=(val) numbers.algorithm = val end |
#send_to_ate ⇒ Object
129 130 131 |
# File 'lib/test_ids/configuration.rb', line 129 def send_to_ate @send_to_ate end |
#send_to_ate=(val) ⇒ Object
125 126 127 |
# File 'lib/test_ids/configuration.rb', line 125 def send_to_ate=(val) @send_to_ate = val end |
#softbins(&block) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/test_ids/configuration.rb', line 99 def softbins(&block) @softbins ||= Item.new if block_given? @softbins.callback(&block) end @softbins end |
#softbins=(val) ⇒ Object
An alias for config.softbins.algorithm=
108 109 110 |
# File 'lib/test_ids/configuration.rb', line 108 def softbins=(val) softbins.algorithm = val end |
#to_json(*a) ⇒ Object
158 159 160 161 162 163 164 |
# File 'lib/test_ids/configuration.rb', line 158 def to_json(*a) { 'bins' => bins, 'softbins' => softbins, 'numbers' => numbers }.to_json(*a) end |
#validate! ⇒ Object
133 134 135 136 137 138 139 140 141 |
# File 'lib/test_ids/configuration.rb', line 133 def validate! unless validated? if bins.algorithm fail 'The TestIds bins configuration cannot be set to an algorithm, only a range set by bins.include and bins.exclude is permitted' end @validated = true freeze end end |
#validated? ⇒ Boolean
147 148 149 |
# File 'lib/test_ids/configuration.rb', line 147 def validated? @validated end |