Module: Tadpole::Filters::InstanceMethods
- Defined in:
- lib/tadpole/filters.rb
Instance Method Summary collapse
- #call_before_method(meth, pass_args = true) ⇒ Object
- #run_before_run ⇒ Object
- #run_before_sections ⇒ Object
Instance Method Details
#call_before_method(meth, pass_args = true) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/tadpole/filters.rb', line 48 def call_before_method(meth, pass_args = true) if meth.is_a?(Symbol) meth = method(meth) args = meth.arity == 0 ? [] : [current_section] meth.call(*args) else instance_eval(&meth) end end |
#run_before_run ⇒ Object
30 31 32 33 34 35 |
# File 'lib/tadpole/filters.rb', line 30 def run_before_run self.class.before_run_filters.each do |meth| result = call_before_method(meth, false) return result if result.is_a?(FalseClass) end end |
#run_before_sections ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tadpole/filters.rb', line 37 def run_before_sections self.class.before_section_filters.each do |info| result, sec, meth = nil, *info if sec.nil? || sec.to_s == current_section.to_s result = call_before_method(meth) end return result if result.is_a?(FalseClass) end end |