Class: ActionController::Base
- Inherits:
-
Object
- Object
- ActionController::Base
- Defined in:
- lib/freshy_filter_chain.rb
Class Method Summary collapse
- .immediate_subclasses ⇒ Object
- .inherited_with_subclass_recording(child) ⇒ Object
- .record_filter_chain_ops_for(*filter_methods) ⇒ Object
- .recorded_filter_chain_ops ⇒ Object
- .refresh_subclass_filter_chains ⇒ Object
- .replay_filter_chain_ops ⇒ Object
Class Method Details
.immediate_subclasses ⇒ Object
38 39 40 |
# File 'lib/freshy_filter_chain.rb', line 38 def immediate_subclasses @immediate_subclasses ||= [] end |
.inherited_with_subclass_recording(child) ⇒ Object
42 43 44 45 |
# File 'lib/freshy_filter_chain.rb', line 42 def inherited_with_subclass_recording(child) immediate_subclasses << child inherited_without_subclass_recording(child) end |
.record_filter_chain_ops_for(*filter_methods) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/freshy_filter_chain.rb', line 7 def self.record_filter_chain_ops_for(*filter_methods) filter_methods.each do |meth| class_eval <<-CODE def #{meth}_with_recording(*filters, &block) filter_operation = lambda { #{meth}_without_recording(*filters, &block) } filter_operation.call recorded_filter_chain_ops << filter_operation refresh_subclass_filter_chains end alias_method_chain meth, :recording CODE end end |
.recorded_filter_chain_ops ⇒ Object
48 49 50 |
# File 'lib/freshy_filter_chain.rb', line 48 def recorded_filter_chain_ops @recorded_filter_chain_ops ||= [] end |
.refresh_subclass_filter_chains ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/freshy_filter_chain.rb', line 26 def refresh_subclass_filter_chains immediate_subclasses.each do |child| child.write_inheritable_attribute('filter_chain', filter_chain.dup) child.replay_filter_chain_ops child.refresh_subclass_filter_chains end end |
.replay_filter_chain_ops ⇒ Object
34 35 36 |
# File 'lib/freshy_filter_chain.rb', line 34 def replay_filter_chain_ops recorded_filter_chain_ops.each { |filter_chain_op| filter_chain_op.call } end |