Module: Sinatra::Contrib::Loader
- Included in:
- Sinatra::Contrib, Common, Custom
- Defined in:
- lib/sinatra/contrib/setup.rb
Instance Method Summary (collapse)
- - (Object) autoload(name, path = nil, method = nil)
- - (Object) extensions
- - (Object) helpers(name, path = nil)
- - (Object) register(name, path = nil)
- - (Object) registered(base)
Instance Method Details
- (Object) autoload(name, path = nil, method = nil)
20 21 22 23 24 |
# File 'lib/sinatra/contrib/setup.rb', line 20 def autoload(name, path = nil, method = nil) path ||= "sinatra/#{name.to_s.underscore}" extensions[method] << name if method Sinatra.autoload(name, path) end |
- (Object) extensions
8 9 10 |
# File 'lib/sinatra/contrib/setup.rb', line 8 def extensions @extensions ||= {:helpers => [], :register => []} end |
- (Object) helpers(name, path = nil)
16 17 18 |
# File 'lib/sinatra/contrib/setup.rb', line 16 def helpers(name, path = nil) autoload name, path, :helpers end |
- (Object) register(name, path = nil)
12 13 14 |
# File 'lib/sinatra/contrib/setup.rb', line 12 def register(name, path = nil) autoload name, path, :register end |
- (Object) registered(base)
26 27 28 29 30 31 |
# File 'lib/sinatra/contrib/setup.rb', line 26 def registered(base) @extensions.each do |meth, list| list = list.map { |name| Sinatra.const_get name } base.send(meth, *list) unless base == ::Sinatra::Application end end |