Module: RightScale::Actor::ClassMethods
- Defined in:
- lib/right_agent/actor.rb
Instance Method Summary collapse
-
#default_prefix ⇒ Object
Construct default prefix by which actor is identified in requests.
-
#expose_idempotent(*methods) ⇒ Object
Add methods to list of services supported by actor and mark these methods as idempotent.
-
#expose_non_idempotent(*methods) ⇒ Object
(also: #expose)
Add methods to list of services supported by actor By default these methods are not idempotent.
-
#idempotent?(method) ⇒ Boolean
Determine whether actor method is idempotent.
-
#provides_for(prefix) ⇒ Object
Get /prefix/method paths that actor responds to.
Instance Method Details
#default_prefix ⇒ Object
Construct default prefix by which actor is identified in requests
Return
- prefix(String)
-
Default prefix
58 59 60 |
# File 'lib/right_agent/actor.rb', line 58 def default_prefix prefix = to_s.to_const_path end |
#expose_idempotent(*methods) ⇒ Object
Add methods to list of services supported by actor and mark these methods as idempotent
Parameters
- methods(Array)
-
Symbol names for methods being exposed as actor idempotent services
Return
- true
-
Always return true
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/right_agent/actor.rb', line 70 def expose_idempotent(*methods) @exposed ||= {} methods.each do |m| if @exposed[m] == false Log.warning("Method #{m} declared both idempotent and non-idempotent, assuming non-idempotent") else @exposed[m] = true end end true end |
#expose_non_idempotent(*methods) ⇒ Object Also known as: expose
Add methods to list of services supported by actor By default these methods are not idempotent
Parameters
- meths(Array)
-
Symbol names for methods being exposed as actor services
Return
- true
-
Always return true
90 91 92 93 94 95 96 97 |
# File 'lib/right_agent/actor.rb', line 90 def expose_non_idempotent(*methods) @exposed ||= {} methods.each do |m| Log.warning("Method #{m} declared both idempotent and non-idempotent, assuming non-idempotent") if @exposed[m] @exposed[m] = false end true end |
#idempotent?(method) ⇒ Boolean
Determine whether actor method is idempotent
Parameters
- method(Symbol)
-
Name for actor method
Return
- (Boolean)
-
true if idempotent, false otherwise
127 128 129 |
# File 'lib/right_agent/actor.rb', line 127 def idempotent?(method) @exposed[method] if @exposed end |
#provides_for(prefix) ⇒ Object
Get /prefix/method paths that actor responds to
Parameters
- prefix(String)
-
Prefix by which actor is identified in requests
Return
- (Array)
-
/prefix/method strings
108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/right_agent/actor.rb', line 108 def provides_for(prefix) return [] unless @exposed @exposed.each_key.select do |method| if instance_methods.include?(method.to_s) or instance_methods.include?(method.to_sym) true else Log.warning("Exposing non-existing method #{method} in actor #{prefix}") false end end.map { |method| "/#{prefix}/#{method}".squeeze('/') } end |