Class: Tracing::Filter::Executor
- Defined in:
- lib/filters/executor/filter_exec.rb
Overview
enable execution of filters
Instance Attribute Summary collapse
-
#filters ⇒ Object
Returns the value of attribute filters.
-
#final_yield_action ⇒ Object
Returns the value of attribute final_yield_action.
Instance Method Summary collapse
-
#filters_allow?(msg, context) ⇒ Boolean
determine if message and context should pass through filter chain return: - true to allow - false to disallow.
-
#initialize(options) ⇒ Executor
constructor
A new instance of Executor.
Constructor Details
#initialize(options) ⇒ Executor
Returns a new instance of Executor.
7 8 9 10 11 12 13 |
# File 'lib/filters/executor/filter_exec.rb', line 7 def initialize() @final_yield_action = [:final_yield_action] || :exclude @filters ||= [] _filters = .filters # puts "filters exec: #{_filters.inspect}" @filters.add(_filters) end |
Instance Attribute Details
#filters ⇒ Object
Returns the value of attribute filters.
5 6 7 |
# File 'lib/filters/executor/filter_exec.rb', line 5 def filters @filters end |
#final_yield_action ⇒ Object
Returns the value of attribute final_yield_action.
5 6 7 |
# File 'lib/filters/executor/filter_exec.rb', line 5 def final_yield_action @final_yield_action end |
Instance Method Details
#filters_allow?(msg, context) ⇒ Boolean
determine if message and context should pass through filter chain return:
-
true to allow
-
false to disallow
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/filters/executor/filter_exec.rb', line 19 def filters_allow?(msg, context) # puts "method: filters_allow?" # default allow return value allow = (final_yield_action == :exclude ? false : true) puts "default allow: #{allow}" # puts "filters: #{@filters}" return allow if @filters.blank? puts "iterate filters" @filters.each do |_filter| puts "filter:" + _filter.inspect # apply filter if _filter res = _filter.allow_action(msg, context) puts "res: #{res}" if (res == :include_and_yield) allow = true end if (res == :exclude_and_yield) allow = false end if (res == :include) # puts "included - break" allow = true break end if (res == :exclude) # puts "excluded - break" allow = false break end # puts "yielding..." else puts "filter is null" end end # puts "filters_allow?: #{allow}" return allow end |