Module: Sinatra::Contrib::Loader

Included in:
Sinatra::Contrib, Common, Custom
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/contrib/setup.rb

Instance Method Summary collapse

Instance Method Details

#autoload(name, path, method = nil) ⇒ Object



21
22
23
24
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/contrib/setup.rb', line 21

def autoload(name, path, method = nil)
  extensions[method] << name if method
  Sinatra.autoload(name, path)
end

#extensionsObject



9
10
11
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/contrib/setup.rb', line 9

def extensions
  @extensions ||= { helpers: [], register: [] }
end

#helpers(name, path) ⇒ Object



17
18
19
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/contrib/setup.rb', line 17

def helpers(name, path)
  autoload name, path, :helpers
end

#register(name, path) ⇒ Object



13
14
15
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/contrib/setup.rb', line 13

def register(name, path)
  autoload name, path, :register
end

#registered(base) ⇒ Object



26
27
28
29
30
31
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/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