Module: Sprout::Daemon::ClassMethods

Defined in:
lib/sprout/daemon.rb

Overview

These are the methods that will be available on any class that includes Sprout::Daemon.

Instance Method Summary (collapse)

Instance Method Details

- (Object) add_action(name, arguments = nil, options = nil)

Add an action that can be called while the long-lived process is active.

This method should raise a Sprout::Errors::UsageError if the provided action name is already defined for the provided instance.



72
73
74
75
76
77
# File 'lib/sprout/daemon.rb', line 72

def add_action name, arguments=nil, options=nil
  options ||= {}
  options[:name] = name
  options[:arguments] = arguments
  create_action_method options
end

- (Object) add_action_alias(alias_name, source_name)

Create an (often shorter) alias to another action name.



82
83
84
85
86
# File 'lib/sprout/daemon.rb', line 82

def add_action_alias alias_name, source_name
  define_method(alias_name) do |*params|
    self.send(source_name, params)
  end
end