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.
37 38 39 40 |
# File 'lib/test_ids/configuration.rb', line 37 def initialize(id) @id = id @allocator = Allocator.new(self) end |
Instance Attribute Details
#allocator ⇒ Object (readonly)
Returns the value of attribute allocator.
35 36 37 |
# File 'lib/test_ids/configuration.rb', line 35 def allocator @allocator end |
Instance Method Details
#bins ⇒ Object
46 47 48 |
# File 'lib/test_ids/configuration.rb', line 46 def bins @bins ||= Item.new end |
#empty? ⇒ Boolean
89 90 91 |
# File 'lib/test_ids/configuration.rb', line 89 def empty? bins.empty? && softbins.empty? && numbers.empty? end |
#freeze ⇒ Object
97 98 99 100 101 102 |
# File 'lib/test_ids/configuration.rb', line 97 def freeze bins.freeze softbins.freeze numbers.freeze super end |
#id ⇒ Object
42 43 44 |
# File 'lib/test_ids/configuration.rb', line 42 def id @id end |
#numbers(&block) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/test_ids/configuration.rb', line 63 def numbers(&block) @numbers ||= Item.new if block_given? @numbers.callback(&block) end @numbers end |
#numbers=(val) ⇒ Object
An alias for config.numbers.algorithm=
72 73 74 |
# File 'lib/test_ids/configuration.rb', line 72 def numbers=(val) numbers.algorithm = val end |
#softbins ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/test_ids/configuration.rb', line 50 def softbins @softbins ||= Item.new if block_given? @softbins.callback(&block) end @softbins end |
#softbins=(val) ⇒ Object
An alias for config.softbins.algorithm=
59 60 61 |
# File 'lib/test_ids/configuration.rb', line 59 def softbins=(val) softbins.algorithm = val end |
#validate! ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/test_ids/configuration.rb', line 76 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
93 94 95 |
# File 'lib/test_ids/configuration.rb', line 93 def validated? @validated end |