Sha256: a4a3999004f513526dd5357a9d4670a8c774e5e718d8ea5ea32181bec7b855ce

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

if defined?(Padrino::Application) # Extends padrino application if being used
  module Padrino
    module ControllerNamespacing
      # Makes the routes defined in the block and in the Modules given
      # in `extensions` available to the application
      def controllers_with_namespaces(*namespace, &block)
        must_use_namespaces = namespace.size == 1 and namespace.first.is_a?(Symbol)
        return controllers_without_namespaces(*namespace, &block) unless must_use_namespaces
        self.reset_routes! if reload?
        namespace(namespace.first) { instance_eval(&block) } if block_given?
      end

      # Makes the routing urls defined in this block and in the Modules given
      # in `extensions` available to the application
      def urls(*extensions, &block)
        instance_eval(&block) if block_given?
        include(*extensions)  if extensions.any?
      end
    end

    class Application
      extend Padrino::ControllerNamespacing
      class << self
        alias_method_chain :controllers, :namespaces
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
padrino-routing-0.1.5 lib/padrino-routing/controller_ext.rb
padrino-routing-0.1.4 lib/padrino-routing/controller_ext.rb
padrino-routing-0.1.3 lib/padrino-routing/controller_ext.rb