module ContextFilters::Context::Local
allow defining local filters and evaluating code in context of thems
Public Instance Methods
evaluate_local_filters(target, method)
click to toggle source
iterates over local_filters
and applies them to the given method
@param method [Proc] a method to call with each filter stored in
+local_filters+
@api private
# 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, &block)
click to toggle source
temporarly adds filter_block
to the list of filters to run and yields given block of code
@param filter_block [Proc] a block of code to add to the list @yield a block in which local_filters
temporarily includes filter_block
# 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()
click to toggle source
@return [Array<Proc>] list of blocks to evaluate @api private
# File lib/context-filters/context/local.rb, line 16 def local_filters @local_filters ||= [] end