Class: Contr::Base
- Inherits:
-
Object
- Object
- Contr::Base
- Defined in:
- lib/contr/base.rb
Class Attribute Summary collapse
-
.config ⇒ Object
readonly
Returns the value of attribute config.
-
.expectations ⇒ Object
readonly
Returns the value of attribute expectations.
-
.guarantees ⇒ Object
readonly
Returns the value of attribute guarantees.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#expectations ⇒ Object
readonly
Returns the value of attribute expectations.
-
#guarantees ⇒ Object
readonly
Returns the value of attribute guarantees.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#main_pool ⇒ Object
readonly
Returns the value of attribute main_pool.
-
#rules_pool ⇒ Object
readonly
Returns the value of attribute rules_pool.
-
#sampler ⇒ Object
readonly
Returns the value of attribute sampler.
Class Method Summary collapse
- .async(async) ⇒ Object
- .expect(name, &block) ⇒ Object
- .guarantee(name, &block) ⇒ Object
- .logger(logger) ⇒ Object
- .sampler(sampler) ⇒ Object
Instance Method Summary collapse
- #check(*args) ⇒ Object
- #check_async(*args) ⇒ Object
-
#initialize(instance_config = {}) ⇒ Base
constructor
A new instance of Base.
- #name ⇒ Object
Constructor Details
#initialize(instance_config = {}) ⇒ Base
Returns a new instance of Base.
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/contr/base.rb', line 48 def initialize(instance_config = {}) @config = merge_configs(instance_config) init_logger! init_sampler! init_main_pool! init_rules_pool! aggregate_guarantees! aggregate_expectations! freeze end |
Class Attribute Details
.config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/contr/base.rb', line 6 def config @config end |
.expectations ⇒ Object (readonly)
Returns the value of attribute expectations.
6 7 8 |
# File 'lib/contr/base.rb', line 6 def expectations @expectations end |
.guarantees ⇒ Object (readonly)
Returns the value of attribute guarantees.
6 7 8 |
# File 'lib/contr/base.rb', line 6 def guarantees @guarantees end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
46 47 48 |
# File 'lib/contr/base.rb', line 46 def config @config end |
#expectations ⇒ Object (readonly)
Returns the value of attribute expectations.
46 47 48 |
# File 'lib/contr/base.rb', line 46 def expectations @expectations end |
#guarantees ⇒ Object (readonly)
Returns the value of attribute guarantees.
46 47 48 |
# File 'lib/contr/base.rb', line 46 def guarantees @guarantees end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
46 47 48 |
# File 'lib/contr/base.rb', line 46 def logger @logger end |
#main_pool ⇒ Object (readonly)
Returns the value of attribute main_pool.
46 47 48 |
# File 'lib/contr/base.rb', line 46 def main_pool @main_pool end |
#rules_pool ⇒ Object (readonly)
Returns the value of attribute rules_pool.
46 47 48 |
# File 'lib/contr/base.rb', line 46 def rules_pool @rules_pool end |
#sampler ⇒ Object (readonly)
Returns the value of attribute sampler.
46 47 48 |
# File 'lib/contr/base.rb', line 46 def sampler @sampler end |
Class Method Details
.async(async) ⇒ Object
8 9 10 |
# File 'lib/contr/base.rb', line 8 def async(async) set_config(:async, async) end |
.expect(name, &block) ⇒ Object
24 25 26 |
# File 'lib/contr/base.rb', line 24 def expect(name, &block) add_expectation(name, block) end |
.guarantee(name, &block) ⇒ Object
20 21 22 |
# File 'lib/contr/base.rb', line 20 def guarantee(name, &block) add_guarantee(name, block) end |
.logger(logger) ⇒ Object
12 13 14 |
# File 'lib/contr/base.rb', line 12 def logger(logger) set_config(:logger, logger) end |
.sampler(sampler) ⇒ Object
16 17 18 |
# File 'lib/contr/base.rb', line 16 def sampler(sampler) set_config(:sampler, sampler) end |
Instance Method Details
#check(*args) ⇒ Object
62 63 64 65 66 |
# File 'lib/contr/base.rb', line 62 def check(*args) result = yield Matcher::Sync.new(self, args, result).match result end |
#check_async(*args) ⇒ Object
68 69 70 71 72 |
# File 'lib/contr/base.rb', line 68 def check_async(*args) result = yield Matcher::Async.new(self, args, result).match result end |
#name ⇒ Object
74 75 76 |
# File 'lib/contr/base.rb', line 74 def name self.class.name end |