Module: Rails3::Plugin::Extender::LoadHandler
Instance Method Summary
collapse
Methods included from Util
#act_type?, #get_base_class, #get_constant, #get_load_type, #get_module, #make_constant, #rails_const_base
Instance Method Details
#after(type, &block) ⇒ Object
15
16
17
18
19
|
# File 'lib/r3_plugin_toolbox/extender/load_handler.rb', line 15
def after type, &block
type = type.to_sym
raise ArgumentError, "#{type} is not a valid after hook" if !valid_after_hook? type
load_handling :"after_#{type}", &block
end
|
#before(type, &block) ⇒ Object
9
10
11
12
13
|
# File 'lib/r3_plugin_toolbox/extender/load_handler.rb', line 9
def before type, &block
type = type.to_sym
raise ArgumentError, "#{type} is not a valid before hook" if !valid_before_hook? type
load_handling :"before_#{type}", &block
end
|
#load_handling(type, &block) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/r3_plugin_toolbox/extender/load_handler.rb', line 27
def load_handling type, &block
ActiveSupport.on_load type do
extend Rails3::Plugin::Extender::DSL
if block
block.arity < 1 ? self.instance_eval(&block) : block.call(self)
end
end
end
|
#on_load(type, &block) ⇒ Object
21
22
23
24
25
|
# File 'lib/r3_plugin_toolbox/extender/load_handler.rb', line 21
def on_load type, &block
type = get_load_type type
raise ArgumentError, "#{type} is not a valid load hook" if !valid_load_hook? type
load_handling type, &block
end
|