Sha256: ddc7e89877b8224b06cfb97a76f7a084c8cb18de04cc2ea8e3e71b2709cb4975

Contents?: true

Size: 936 Bytes

Versions: 3

Compression:

Stored size: 936 Bytes

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(*args, &block)
        return controllers_without_namespaces(*args, &block) unless args.all? { |a| a.kind_of?(Symbol) }
        namespace(*args) { 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.5.0 lib/padrino-routing/controller_ext.rb
padrino-routing-0.4.6 lib/padrino-routing/controller_ext.rb
padrino-routing-0.4.5 lib/padrino-routing/controller_ext.rb