Sha256: 86b516692ec1880679d7d2cbc66781fc3d48511379d55528bc90470d4dc1f8a7

Contents?: true

Size: 1.27 KB

Versions: 19

Compression:

Stored size: 1.27 KB

Contents

module ActionDispatch::Routing
  class Mapper
   
    # Is equivelant to 
    #  
    # namespace :admin do
    #   resource :product
    # end
    #
    #
    
    def cable_to(*resources, &block)

      options = resources.extract_options!
      path = "admin"
      admin_namespace = { :path => path, :as => path, :module => path,
                           :shallow_path => path, :shallow_prefix => path }
      scope(admin_namespace) do 

        if apply_common_behavior_for(:resources, resources, options, &block)
          return self
        end

        resource_scope(Resource.new(resources.pop, options)) do
          yield if block_given?

          collection do
            get  :index if parent_resource.actions.include?(:index)
            post :create if parent_resource.actions.include?(:create)
          end

          new do
            get :new
          end if parent_resource.actions.include?(:new)

          member do
            get    :edit if parent_resource.actions.include?(:edit)
            get    :show if parent_resource.actions.include?(:show)
            put    :update if parent_resource.actions.include?(:update)
            delete :destroy if parent_resource.actions.include?(:destroy)
          end
        end
      end
      self
    end
    
    
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
cable-0.9.17 lib/cable/rails/routes.rb
cable-0.9.16 lib/cable/rails/routes.rb
cable-0.9.15 lib/cable/rails/routes.rb
cable-0.9.14 lib/cable/rails/routes.rb
cable-0.9.13 lib/cable/rails/routes.rb
cable-0.9.12 lib/cable/rails/routes.rb
cable-0.9.11 lib/cable/rails/routes.rb
cable-0.9.10 lib/cable/rails/routes.rb
cable-0.9.9 lib/cable/rails/routes.rb
cable-0.9.8 lib/cable/rails/routes.rb
cable-0.9.6 lib/cable/rails/routes.rb
cable-0.9.5 lib/cable/rails/routes.rb
cable-0.9.4 lib/cable/rails/routes.rb
cable-0.9.3 lib/cable/rails/routes.rb
cable-0.9.1 lib/cable/rails/routes.rb
cable-0.9.0 lib/cable/rails/routes.rb
cable-0.8.6 lib/cable/rails/routes.rb
cable-0.8.5 lib/cable/rails/routes.rb
cable-0.8.4 lib/cable/rails/routes.rb