Sha256: 06aaa87953b8f04b250699dd36f4c31103b9f682a1e46a4241c064e449b3a76b

Contents?: true

Size: 1.09 KB

Versions: 31

Compression:

Stored size: 1.09 KB

Contents

require 'sinatra/base'
require 'sinatra/contrib/version'
require 'backports'

module Sinatra
  module Contrib
    module Loader
      def extensions
        @extensions ||= {:helpers => [], :register => []}
      end

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

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

      def autoload(name, path = nil, method = nil)
        path ||= "sinatra/#{name.to_s.underscore}"
        extensions[method] << name if method
        Sinatra.autoload(name, path)
      end

      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
    end

    module Common
      extend Loader
    end

    module Custom
      extend Loader
    end

    module All
      def self.registered(base)
        base.register Common, Custom
      end
    end

    extend Loader
    def self.registered(base)
      base.register Common, Custom
    end
  end
end

Version data entries

31 entries across 31 versions & 4 rubygems

Version Path
sinatra-contrib-2.0.2 lib/sinatra/contrib/setup.rb
sinatra-contrib-2.0.1 lib/sinatra/contrib/setup.rb
sinatra-contrib-2.0.1.rc1 lib/sinatra/contrib/setup.rb
sinatra-contrib-2.0.0 lib/sinatra/contrib/setup.rb
sinatra-contrib-2.0.0.rc6 lib/sinatra/contrib/setup.rb
sinatra-contrib-2.0.0.rc5 lib/sinatra/contrib/setup.rb
sinatra-contrib-2.0.0.rc2 lib/sinatra/contrib/setup.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/sinatra-contrib-1.4.7/lib/sinatra/contrib/setup.rb
sinatra-contrib-2.0.0.rc1 lib/sinatra/contrib/setup.rb
sinatra-contrib-2.0.0.beta2 lib/sinatra/contrib/setup.rb
sinatra-contrib-2.0.0.beta1 lib/sinatra/contrib/setup.rb
sinatra-contrib-1.4.7 lib/sinatra/contrib/setup.rb
sinatra-contrib-1.4.6 lib/sinatra/contrib/setup.rb
sinatra-contrib-1.4.4 lib/sinatra/contrib/setup.rb
scout_realtime-1.0.5 lib/vendor/sinatra-contrib-1.4.1/lib/sinatra/contrib/setup.rb
scout_realtime-1.0.4 lib/vendor/sinatra-contrib-1.4.1/lib/sinatra/contrib/setup.rb
scout_realtime-1.0.3 lib/vendor/sinatra-contrib-1.4.1/lib/sinatra/contrib/setup.rb
scout_realtime-1.0.3.pre lib/vendor/sinatra-contrib-1.4.1/lib/sinatra/contrib/setup.rb
scout_realtime-1.0.2 lib/vendor/sinatra-contrib-1.4.1/lib/sinatra/contrib/setup.rb
scout_realtime-1.0.1 lib/vendor/sinatra-contrib-1.4.1/lib/sinatra/contrib/setup.rb