Sha256: 8ecbc512787dc82222b810d10f7cd53e494bf16b53a253df4ec7bb7c34b7ace7

Contents?: true

Size: 902 Bytes

Versions: 4

Compression:

Stored size: 902 Bytes

Contents

module Plutonium
  module Core
    module Actions
      class Collection
        delegate_missing_to :@collection

        def initialize(collection = {})
          @collection = collection
        end

        def permitted_for(policy)
          Collection.new(@collection.select { |name, action| policy.send :"#{action.name}?" })
        end

        def collection_actions
          Collection.new(@collection.select { |name, action| action.collection_action? })
        end

        def collection_record_actions
          Collection.new(@collection.select { |name, action| action.collection_record_action? })
        end

        def record_actions
          Collection.new(@collection.select { |name, action| action.record_action? })
        end

        def bulk_actions
          Collection.new(@collection.select { |name, action| action.bulk_action? })
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
plutonium-0.6.2 lib/plutonium/core/actions/collection.rb
plutonium-0.6.1 lib/plutonium/core/actions/collection.rb
plutonium-0.6.0 lib/plutonium/core/actions/collection.rb
plutonium-0.5.0 lib/plutonium/core/actions/collection.rb