Module: ContextFilters::Context::Local
- Included in:
- ContextFilters::Context
- Defined in:
- lib/context-filters/context/local.rb
Overview
allow defining local filters and evaluating code in context of thems
Instance Method Summary collapse
-
#evaluate_local_filters(target, method) ⇒ Object
private
iterates over
local_filters
and applies them to the givenmethod
. -
#local_filter(filter_block) { ... } ⇒ Object
temporarly adds
filter_block
to the list of filters to run and yields given block of code. -
#local_filters ⇒ Array<Proc>
private
List of blocks to evaluate.
Instance Method Details
#evaluate_local_filters(target, method) ⇒ 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.
iterates over local_filters
and applies them to the given method
37 38 39 |
# File 'lib/context-filters/context/local.rb', line 37 def evaluate_local_filters(target, method) local_filters.each { |block| target.send(method, &block) } end |
#local_filter(filter_block) { ... } ⇒ Object
temporarly adds filter_block
to the list of filters to run and yields given block of code
25 26 27 28 29 30 |
# File 'lib/context-filters/context/local.rb', line 25 def local_filter(filter_block, &block) local_filters.push(filter_block) block.call ensure local_filters.pop end |
#local_filters ⇒ Array<Proc>
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 list of blocks to evaluate.
16 17 18 |
# File 'lib/context-filters/context/local.rb', line 16 def local_filters @local_filters ||= [] end |