Class: Emissary::Agent
Defined Under Namespace
Classes: Emissary, Error, File, Gem, Mysql, Ping, Proxy, Rabbitmq, Stats, Test
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
Instance Method Summary collapse
- #activate ⇒ Object
-
#initialize(message, config, operator) ⇒ Agent
constructor
A new instance of Agent.
- #post_init ⇒ Object
- #send(message) ⇒ Object
- #valid_methods ⇒ Object
Constructor Details
#initialize(message, config, operator) ⇒ Agent
Returns a new instance of Agent.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/emissary/agent.rb', line 21 def initialize , config, operator @message = @operator = operator @config = config @method = .method.to_sym rescue :__bad_method__ @args = .args.clone unless valid_methods.first == :any or valid_methods.include? @method raise ArgumentError, "Invalid method '#{@method.to_s}' for agent '#{.agent}'" end post_init end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
19 20 21 |
# File 'lib/emissary/agent.rb', line 19 def args @args end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
18 19 20 |
# File 'lib/emissary/agent.rb', line 18 def config @config end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
18 19 20 |
# File 'lib/emissary/agent.rb', line 18 def @message end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
18 19 20 |
# File 'lib/emissary/agent.rb', line 18 def method @method end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/emissary/agent.rb', line 18 def name @name end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
18 19 20 |
# File 'lib/emissary/agent.rb', line 18 def operator @operator end |
Instance Method Details
#activate ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/emissary/agent.rb', line 42 def activate catch(:skip_implicit_response) do result = self.__send__(method, *args) response = if not result.kind_of? ::Emissary::Message response = .response response.status = [ :ok, (result == true || result.nil? ? 'Succeeded.' : result ) ] response else result end send response end end |
#post_init ⇒ Object
36 |
# File 'lib/emissary/agent.rb', line 36 def post_init(); end |
#send(message) ⇒ Object
57 58 59 |
# File 'lib/emissary/agent.rb', line 57 def send operator.send end |
#valid_methods ⇒ Object
38 39 40 |
# File 'lib/emissary/agent.rb', line 38 def valid_methods raise StandardError, 'Not implemented' end |