Class: Sanford::Protocol::MsgData
- Inherits:
-
Object
- Object
- Sanford::Protocol::MsgData
show all
- Defined in:
- lib/sanford-protocol/msg_data.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(called_from = nil, &get_value) ⇒ MsgData
Returns a new instance of MsgData.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/sanford-protocol/msg_data.rb', line 14
def initialize(called_from = nil, &get_value)
begin
@value = get_value.call
rescue Exception => err
@called_from = called_from || caller
ENV['SANFORD_PROTOCOL_DEBUG'] ? raise(err) : self.error!(self.get_value_error)
end
end
|
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
12
13
14
|
# File 'lib/sanford-protocol/msg_data.rb', line 12
def value
@value
end
|
Instance Method Details
#error!(message) ⇒ Object
32
33
34
|
# File 'lib/sanford-protocol/msg_data.rb', line 32
def error!(message)
raise BadMessageError.new(message, @called_from)
end
|
#get_value_error ⇒ Object
29
|
# File 'lib/sanford-protocol/msg_data.rb', line 29
def get_value_error; "Error reading the message"; end
|
#validate! ⇒ Object
30
|
# File 'lib/sanford-protocol/msg_data.rb', line 30
def validate!; self; end
|