Module: Ramaze::Contrib
- Defined in:
- lib/ramaze/contrib.rb,
lib/ramaze/contrib/profiling.rb,
lib/ramaze/contrib/auto_params.rb
Overview
A module used for loading contrib modules.
Defined Under Namespace
Classes: AutoParams, Gettext, Profiling
Class Method Summary collapse
-
.load(*contribs) ⇒ Object
Loads and sets up contrib modules from /ramaze/contrib.
-
.shutdown ⇒ Object
Will call .shutdown on all contrib modules which support it.
-
.startup(options = {}) ⇒ Object
Will load all contrib modules from options — .startup gets called by Ramaze :essentials.
Class Method Details
.load(*contribs) ⇒ Object
Loads and sets up contrib modules from /ramaze/contrib.
Usage:
Ramaze::Contrib.load :gzip_filter
Creating a contrib module:
module Ramaze::Contrib::Test
def self.setup
Log.info "Test module set up"
end
end
class TestController < Ramaze::Controller
map '/test'
def index; "Chunky Bacon!"; end
end
# Save that to your <app dir>/contrib and use like:
Ramaze.contrib :test
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ramaze/contrib.rb', line 43 def self.load(*contribs) contribs.each do |name| mod_name = name.to_s.camel_case begin const = Contrib.const_get(mod_name) Global.contribs << const const.startup if const.respond_to?(:startup) Log.dev "Loaded contrib: #{const}" rescue NameError files = Dir["{contrib,#{BASEDIR/:ramaze/:contrib}}/#{name}.{so,bundle,rb}"] raise LoadError, "#{mod_name} not found" unless files.any? require(files.first) ? retry : raise end end end |