Class: Matchd::Rule::Respond
- Inherits:
-
Matchd::Rule
- Object
- Matchd::Rule
- Matchd::Rule::Respond
- Defined in:
- lib/matchd/rule/respond.rb
Constant Summary
Constants inherited from Matchd::Rule
NotImplementedError, REGEXP_MATCHER, REGEXP_OPTIONS
Instance Attribute Summary collapse
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
Attributes inherited from Matchd::Rule
Instance Method Summary collapse
-
#initialize(options) ⇒ Respond
constructor
A new instance of Respond.
- #visit!(_server, _name, _resource_class, transaction) ⇒ Object
Methods inherited from Matchd::Rule
#call, #match_name, #match_resource_classes, #matches?, parse_match, parse_resource_class
Constructor Details
#initialize(options) ⇒ Respond
Returns a new instance of Respond.
2 3 4 5 |
# File 'lib/matchd/rule/respond.rb', line 2 def initialize() super @responses = .fetch("respond") end |
Instance Attribute Details
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
7 8 9 |
# File 'lib/matchd/rule/respond.rb', line 7 def responses @responses end |
Instance Method Details
#visit!(_server, _name, _resource_class, transaction) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/matchd/rule/respond.rb', line 9 def visit!(_server, _name, _resource_class, transaction) # Using the original Rule's resource_classes definition as a fallback, if # the response doesn't configure one. Matchd.Response(responses, @resource_classes).each do |resp| resp.call(transaction) end end |