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 ⇒ Object
- #empty? ⇒ Boolean
- #freeze ⇒ Object
- #id ⇒ Object
-
#initialize(id) ⇒ Configuration
constructor
A new instance of Configuration.
- #numbers(&block) ⇒ Object
-
#numbers=(val) ⇒ Object
An alias for config.numbers.algorithm=.
- #softbins ⇒ Object
-
#softbins=(val) ⇒ Object
An alias for config.softbins.algorithm=.
- #validate! ⇒ Object
- #validated? ⇒ Boolean
Constructor Details
#initialize(id) ⇒ Configuration
Returns a new instance of Configuration.
36 37 38 39 |
# File 'lib/test_ids/configuration.rb', line 36 def initialize(id) @id = id @allocator = Allocator.new(self) end |
Instance Attribute Details
#allocator ⇒ Object (readonly)
Returns the value of attribute allocator.
34 35 36 |
# File 'lib/test_ids/configuration.rb', line 34 def allocator @allocator end |
Instance Method Details
#bins ⇒ Object
45 46 47 |
# File 'lib/test_ids/configuration.rb', line 45 def bins @bins ||= Item.new end |
#empty? ⇒ Boolean
88 89 90 |
# File 'lib/test_ids/configuration.rb', line 88 def empty? bins.empty? && softbins.empty? && numbers.empty? end |
#freeze ⇒ Object
96 97 98 99 100 101 |
# File 'lib/test_ids/configuration.rb', line 96 def freeze bins.freeze softbins.freeze numbers.freeze super end |
#id ⇒ Object
41 42 43 |
# File 'lib/test_ids/configuration.rb', line 41 def id @id end |
#numbers(&block) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/test_ids/configuration.rb', line 62 def numbers(&block) @numbers ||= Item.new if block_given? @numbers.callback(&block) end @numbers end |
#numbers=(val) ⇒ Object
An alias for config.numbers.algorithm=
71 72 73 |
# File 'lib/test_ids/configuration.rb', line 71 def numbers=(val) numbers.algorithm = val end |
#softbins ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/test_ids/configuration.rb', line 49 def softbins @softbins ||= Item.new if block_given? @softbins.callback(&block) end @softbins end |
#softbins=(val) ⇒ Object
An alias for config.softbins.algorithm=
58 59 60 |
# File 'lib/test_ids/configuration.rb', line 58 def softbins=(val) softbins.algorithm = val end |
#validate! ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/test_ids/configuration.rb', line 75 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 if bins.callback fail 'The TestIds bins configuration cannot be set by a callback, only a range set by bins.include and bins.exclude is permitted' end @validated = true freeze end end |
#validated? ⇒ Boolean
92 93 94 |
# File 'lib/test_ids/configuration.rb', line 92 def validated? @validated end |