Sha256: a41fdf4cc6897e31f6686036fcde5686ae9fdd76e721d061264627f208ccc18f

Contents?: true

Size: 978 Bytes

Versions: 249

Compression:

Stored size: 978 Bytes

Contents

module Katello
  module Routing
    module MapperExtensions
      def api_resources(*args, &block)
        options          = args.extract_options!
        options[:except] = Array(options[:except])
        options[:except].push(:new, :edit)

        args << options
        resources(*args, &block)
      end

      def api_attachable_resources(resource_plural_name, options = {})
        resource_singular_name = options.try(:delete, :resource_name)
        resource_singular_name ||= resource_plural_name.to_s.singularize

        controller = options.delete(:controller)

        api_resources resource_plural_name, :controller => controller, :only => [] do
          params = { :on => :collection, :action => "add_" + resource_singular_name.to_s }
          post :index, params.merge(options)

          params = { :on => :member, :action => "remove_" + resource_singular_name.to_s }
          delete :destroy, params.merge(options)
        end
      end
    end
  end
end

Version data entries

249 entries across 249 versions & 1 rubygems

Version Path
katello-4.14.2 app/lib/katello/api/mapper_extensions.rb
katello-4.15.0 app/lib/katello/routing/mapper_extensions.rb
katello-4.15.0.rc2 app/lib/katello/routing/mapper_extensions.rb
katello-4.15.0.rc1 app/lib/katello/routing/mapper_extensions.rb
katello-4.14.1 app/lib/katello/api/mapper_extensions.rb
katello-4.14.0 app/lib/katello/api/mapper_extensions.rb
katello-4.14.0.rc3 app/lib/katello/api/mapper_extensions.rb
katello-4.14.0.rc2 app/lib/katello/api/mapper_extensions.rb
katello-4.14.0.rc1.1 app/lib/katello/api/mapper_extensions.rb
katello-4.14.0.rc1 app/lib/katello/api/mapper_extensions.rb
katello-4.13.1 app/lib/katello/api/mapper_extensions.rb
katello-4.13.0 app/lib/katello/api/mapper_extensions.rb
katello-4.12.1 app/lib/katello/api/mapper_extensions.rb
katello-4.13.0.rc1 app/lib/katello/api/mapper_extensions.rb
katello-4.12.0 app/lib/katello/api/mapper_extensions.rb
katello-4.12.0.rc3 app/lib/katello/api/mapper_extensions.rb
katello-4.12.0.rc2 app/lib/katello/api/mapper_extensions.rb
katello-4.12.0.rc1 app/lib/katello/api/mapper_extensions.rb
katello-4.11.1 app/lib/katello/api/mapper_extensions.rb
katello-4.11.0 app/lib/katello/api/mapper_extensions.rb