Sha256: 003328045044eba9bad014721c3b606be05fbb71df3b1401702a5fff1d06929c

Contents?: true

Size: 665 Bytes

Versions: 12

Compression:

Stored size: 665 Bytes

Contents

class PageletRails::Router

  def self.load_routes! context
    controllers = Dir[Rails.root.join('app', 'pagelets', '*', '*controller.rb')]

    controllers.each do |controller_file|
      pagelet_name = File.basename(File.dirname(controller_file))

      basename_controller_name = File.basename controller_file, '.rb'
      controller = "#{pagelet_name}/#{basename_controller_name}".camelize.constantize

      next unless controller.respond_to? :load_pagelet_routes!

      context.instance_eval do
        scope module: pagelet_name, path: "/pagelets", as: "pagelets" do
          controller.load_pagelet_routes! self
        end
      end

    end
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pagelet_rails-0.2.2 lib/pagelet_rails/router.rb
pagelet_rails-0.2.1 lib/pagelet_rails/router.rb
pagelet_rails-0.2.0 lib/pagelet_rails/router.rb
pagelet_rails-0.1.8 lib/pagelet_rails/router.rb
pagelet_rails-0.1.7 lib/pagelet_rails/router.rb
pagelet_rails-0.1.6 lib/pagelet_rails/router.rb
pagelet_rails-0.1.5 lib/pagelet_rails/router.rb
pagelet_rails-0.1.4 lib/pagelet_rails/router.rb
pagelet_rails-0.1.3 lib/pagelet_rails/router.rb
pagelet_rails-0.1.2 lib/pagelet_rails/router.rb
pagelet_rails-0.1.1 lib/pagelet_rails/router.rb
pagelet_rails-0.1.0 lib/pagelet_rails/router.rb