Class: Rails::Plugin

Inherits:
Object show all
Defined in:
lib/desert/rails/2.0.0/plugin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#initializerObject

Returns the value of attribute initializer.



2
3
4
# File 'lib/desert/rails/2.0.0/plugin.rb', line 2

def initializer
  @initializer
end

Instance Method Details

#load_with_desert(initializer) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/desert/rails/2.0.0/plugin.rb', line 12

def load_with_desert(initializer)
  @initializer = initializer
  return if Desert::Manager.plugin_exists?(directory)
  plugin = Desert::Manager.register_plugin(directory) do
    load_without_desert(initializer)
  end
  # TODO: Can we use Initializer::Configuration#default_load_paths to do this?
  initializer.configuration.controller_paths << plugin.controllers_path
end

#require_plugin(plugin_name) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/desert/rails/2.0.0/plugin.rb', line 3

def require_plugin(plugin_name)
  initializer.configuration.plugin_locators.each do |locator|
    locator.new(initializer).each do |plugin_loader|
      return plugin_loader.load(initializer) if plugin_loader.name.to_s == plugin_name.to_s
    end
  end
  raise "Plugin '#{plugin_name}' does not exist"
end