Class: Gurke::Configuration::Hook Private
- Inherits:
-
Object
- Object
- Gurke::Configuration::Hook
- Defined in:
- lib/gurke/configuration.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #block ⇒ Object readonly private
- #opts ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(opts, &block) ⇒ Hook
constructor
private
A new instance of Hook.
- #match?(context) ⇒ Boolean private
- #run(context, *args) ⇒ Object private
Constructor Details
#initialize(opts, &block) ⇒ Hook
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Hook.
125 126 127 128 |
# File 'lib/gurke/configuration.rb', line 125 def initialize(opts, &block) @opts = opts @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
123 124 125 |
# File 'lib/gurke/configuration.rb', line 123 def block @block end |
#opts ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
123 124 125 |
# File 'lib/gurke/configuration.rb', line 123 def opts @opts end |
Instance Method Details
#match?(context) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
130 131 132 |
# File 'lib/gurke/configuration.rb', line 130 def match?(context) !opts.any?{|k, v| context.[k] != v } end |
#run(context, *args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
134 135 136 137 138 139 140 141 |
# File 'lib/gurke/configuration.rb', line 134 def run(context, *args) block = @block if context context.instance_exec(*args, &block) else block.call(*args) end end |