Method: Kenji::Controller.before
- Defined in:
- lib/kenji/controller.rb
.before(&block) ⇒ Object
This lets you define before blocks.
class MyController < Kenji::Controller
before do
# eg. ensure authentication, you can use kenji.respond in here.
end
end
101 102 103 104 105 106 |
# File 'lib/kenji/controller.rb', line 101 def self.before(&block) define_method(:_tmp_before_action, &block) block = instance_method(:_tmp_before_action) remove_method(:_tmp_before_action) (@befores ||= []) << block end |