Module: Rails3::Plugin::Extender::Macro

Extended by:
Util
Included in:
RSpec::Core::ExampleGroup
Defined in:
lib/r3_plugin_toolbox/macro.rb

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_init(component, &block) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/r3_plugin_toolbox/macro.rb', line 33

def after_init component, &block
  type = macro.get_load_type component
  Rails3::Plugin::Extender.new do
    extend_rails type do          
      after :initialize do
        yield self
      end
    end
  end        
end

#init_app_railties(app_name, *railties) ⇒ Object

def



44
45
46
47
48
49
50
# File 'lib/r3_plugin_toolbox/macro.rb', line 44

def init_app_railties app_name, *railties
  app = "#{app_name.to_s.camelize}::Application".constantize 
  app.initialize!                        
  railties.each do |railtie|
    macro.get_base_class(railtie).constantize
  end
end

#with_configuration(&block) ⇒ Object



21
22
23
24
25
# File 'lib/r3_plugin_toolbox/macro.rb', line 21

def with_configuration &block
  if block
    block.arity < 1 ? Rails.configuration.instance_eval(&block) : block.call(Rails.configuration)  
  end      
end

#with_engine(name, &block) ⇒ Object



15
16
17
18
19
# File 'lib/r3_plugin_toolbox/macro.rb', line 15

def with_engine name, &block
  Rails3::Engine.new name do |e|
    yield e
  end
end

#with_extension(&block) ⇒ Object



27
28
29
30
31
# File 'lib/r3_plugin_toolbox/macro.rb', line 27

def with_extension &block
  Rails3::Plugin::Extender.new do |e|
    e.instance_eval(&block)
  end
end