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