Class: BSV::Network::Result::Success
- Inherits:
-
Object
- Object
- BSV::Network::Result::Success
- Includes:
- Predicates
- Defined in:
- lib/bsv/network/result.rb
Overview
Represents a successful outcome. Carries the response payload in data and optional protocol-specific extras in metadata.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(data:, metadata: {}) ⇒ Success
constructor
A new instance of Success.
- #success? ⇒ Boolean
Methods included from Predicates
Constructor Details
#initialize(data:, metadata: {}) ⇒ Success
Returns a new instance of Success.
32 33 34 35 36 |
# File 'lib/bsv/network/result.rb', line 32 def initialize(data:, metadata: {}) @data = data @metadata = .freeze freeze end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
30 31 32 |
# File 'lib/bsv/network/result.rb', line 30 def data @data end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
30 31 32 |
# File 'lib/bsv/network/result.rb', line 30 def @metadata end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
42 43 44 |
# File 'lib/bsv/network/result.rb', line 42 def ==(other) other.is_a?(Success) && data == other.data && == other. end |
#hash ⇒ Object
48 49 50 |
# File 'lib/bsv/network/result.rb', line 48 def hash [self.class, data, ].hash end |
#success? ⇒ Boolean
38 39 40 |
# File 'lib/bsv/network/result.rb', line 38 def success? true end |