Sha256: 0be230c6ae4a04b269a18f53b8da5e961c85fdeff8ddb2e41226055ba1488e79

Contents?: true

Size: 1016 Bytes

Versions: 1

Compression:

Stored size: 1016 Bytes

Contents

module Ruroku
  class ProcessSet < NestedResourceSet
    resource_class Process
    collection_api_selector :get_ps

    # Map API methods to collection methods.
    #
    # Examples
    #
    #   processes.run 'rake task'
    #   processes.restart
    #   processes.scale 'web', 10
    #   processes.stop 'ps' => 'web.1'
    #   processes.stop 'type' => 'web'
    map_api run: :post_ps,
      restart: :post_ps_restart,
      scale: :ps_scale,
      stop: :post_ps_stop

    # Public: Find either a process when specified full process name,
    # or a collection of processes, if specified a process type.
    #
    # Examples
    #
    #   processes['web.1']
    #   processes['web']
    #
    # Returns the ProcessSet object if process type was passed, the
    # Process object otherwise.
    def [](process_name)
      if process_name.include? '.'
        select { |process| process.type == process_name }
      else
        select { |process| process.process == process_name }.first
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruroku-0.0.3 lib/ruroku/resource_sets/process_set.rb