Class: ActionService::Protocol::AbstractProtocolMessage
- Inherits:
-
Object
- Object
- ActionService::Protocol::AbstractProtocolMessage
- Defined in:
- lib/action_service/protocol/abstract.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#return_signature ⇒ Object
Returns the value of attribute return_signature.
-
#signature ⇒ Object
Returns the value of attribute signature.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #check_compatibility(expected_class, received_class) ⇒ Object
- #check_parameter_types(values, signature) ⇒ Object
- #checked? ⇒ Boolean
-
#initialize(options = {}) ⇒ AbstractProtocolMessage
constructor
A new instance of AbstractProtocolMessage.
Constructor Details
#initialize(options = {}) ⇒ AbstractProtocolMessage
Returns a new instance of AbstractProtocolMessage.
39 40 41 42 43 |
# File 'lib/action_service/protocol/abstract.rb', line 39 def initialize(={}) @signature = @return_signature = nil @options = @type = @options[:type] || CheckedMessage end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
37 38 39 |
# File 'lib/action_service/protocol/abstract.rb', line 37 def @options end |
#return_signature ⇒ Object
Returns the value of attribute return_signature.
35 36 37 |
# File 'lib/action_service/protocol/abstract.rb', line 35 def return_signature @return_signature end |
#signature ⇒ Object
Returns the value of attribute signature.
34 35 36 |
# File 'lib/action_service/protocol/abstract.rb', line 34 def signature @signature end |
#type ⇒ Object
Returns the value of attribute type.
36 37 38 |
# File 'lib/action_service/protocol/abstract.rb', line 36 def type @type end |
Instance Method Details
#check_compatibility(expected_class, received_class) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/action_service/protocol/abstract.rb', line 72 def check_compatibility(expected_class, received_class) return if \ (expected_class == TrueClass or expected_class == FalseClass) and \ (received_class == TrueClass or received_class == FalseClass) unless received_class.ancestors.include?(expected_class) or \ expected_class.ancestors.include?(received_class) raise(ProtocolError, "value of type #{received_class.name} is not " + "compatible with expected type #{expected_class.name}") end end |
#check_parameter_types(values, signature) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/action_service/protocol/abstract.rb', line 62 def check_parameter_types(values, signature) return unless checked? && signature unless signature.length == values.length raise(ProtocolError, "Signature and parameter lengths mismatch") end (1..signature.length).each do |i| check_compatibility(signature[i-1], values[i-1].class) end end |
#checked? ⇒ Boolean
58 59 60 |
# File 'lib/action_service/protocol/abstract.rb', line 58 def checked? @type == CheckedMessage end |