Sha256: 26574f15f0a1458b0615a18360133c784e2381bca6b11dd2d3e40ae1cf01b9dc

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

# -*- encoding : utf-8 -*-
module RademadeAdmin
  module Routing
    module Mapper

      def admin_resources(*resources, &block)

        admin_resources = resources.dup
        options = admin_resources.extract_options!.dup

        admin_resources.each do |resource|
          resource_scope(:resources, Resource.new(resource, options)) do
            yield if block_given?

            parent_resource_actions = @scope[:scope_level_resource].actions

            collection do
              get :autocomplete
              patch :sort
            end

            new do
              get :form
            end if parent_resource_actions.include? :new

            member do
              get :form if parent_resource_actions.include? :edit

              scope 'related/:relation' do
                get '/' => :related, :as => :related
                get :autocomplete, :link_autocomplete
                post ':related_id' => :related_add, :as => :related_add
                delete ':related_id' => :related_destroy, :as => :related_destroy
              end

            end

            Model::Graph.instance.add_pair(@scope[:controller], self.shallow?)

          end
        end

        resources(*resources, &block)

        self
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rademade_admin-0.1.3 lib/rademade_admin/routing/mapper.rb
rademade_admin-0.1.2 lib/rademade_admin/routing/mapper.rb
rademade_admin-0.1.1 lib/rademade_admin/routing/mapper.rb
rademade_admin-0.1.0 lib/rademade_admin/routing/mapper.rb