Sha256: a538363e7782746f43e29378be084005aecd19fc62ff14e317679fd694900430

Contents?: true

Size: 985 Bytes

Versions: 1

Compression:

Stored size: 985 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

        def values
          super.sort_by { |value| value.position }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
plutonium-0.8.0 lib/plutonium/core/actions/collection.rb