Class: Spectroscope::Hooks::Hook
- Inherits:
-
Object
- Object
- Spectroscope::Hooks::Hook
- Defined in:
- lib/spectroscope/hooks.rb
Overview
Encapsulates a hook procedure along with it’s match tags.
Instance Method Summary collapse
-
#initialize(tense, scope, *tags, &proc) ⇒ Hook
constructor
A brief description of the advice (optional).
-
#match?(it) ⇒ Boolean
Check for matching subjects or tags for each advice.
- #to_proc ⇒ Object
Constructor Details
#initialize(tense, scope, *tags, &proc) ⇒ Hook
A brief description of the advice (optional). attr :subject
77 78 79 80 81 82 |
# File 'lib/spectroscope/hooks.rb', line 77 def initialize(tense, scope, *, &proc) @tense = tense @scope = scope @tags = @proc = proc end |
Instance Method Details
#match?(it) ⇒ Boolean
Check for matching subjects or tags for each advice.
87 88 89 90 91 92 93 |
# File 'lib/spectroscope/hooks.rb', line 87 def match?(it) return true if @tags.empty? @tags.any? do |t| it.match?(t) end end |
#to_proc ⇒ Object
96 97 98 |
# File 'lib/spectroscope/hooks.rb', line 96 def to_proc @proc end |