Class: RabbitRPC::MessageParser
- Inherits:
-
Object
- Object
- RabbitRPC::MessageParser
- Defined in:
- lib/rabbit_rpc/message_parser.rb
Constant Summary collapse
- ONE_WAY_PREFIX =
methods with the following prefix will not wait for a response
'one_way'
Instance Attribute Summary collapse
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
Instance Method Summary collapse
-
#initialize(message) ⇒ MessageParser
constructor
A new instance of MessageParser.
-
#one_way? ⇒ Boolean
Public: Identifies whether a wait for a response is expected.
-
#parse ⇒ Object
Public: Extracts the Service name and method name.
Constructor Details
#initialize(message) ⇒ MessageParser
Returns a new instance of MessageParser.
11 12 13 |
# File 'lib/rabbit_rpc/message_parser.rb', line 11 def initialize() @message = end |
Instance Attribute Details
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
5 6 7 |
# File 'lib/rabbit_rpc/message_parser.rb', line 5 def method_name @method_name end |
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
5 6 7 |
# File 'lib/rabbit_rpc/message_parser.rb', line 5 def service_name @service_name end |
Instance Method Details
#one_way? ⇒ Boolean
Public: Identifies whether a wait for a response is expected
Returns a Boolean
31 32 33 34 |
# File 'lib/rabbit_rpc/message_parser.rb', line 31 def one_way? parse if @method_name.nil? @method_name.start_with?(ONE_WAY_PREFIX) end |
#parse ⇒ Object
Public: Extracts the Service name and method name
Examples
"UserService.create"
# => "UserService", "create"
Returns nothing
23 24 25 26 |
# File 'lib/rabbit_rpc/message_parser.rb', line 23 def parse method = @message.is_a?(RabbitRPC::Message) ? @message.method_name : @message['method'] @service_name, @method_name = method.split('.') end |