Class: BSV::Network::Result::Success

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from Predicates

#error?, #not_found?

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

#dataObject (readonly)

Returns the value of attribute data.



30
31
32
# File 'lib/bsv/network/result.rb', line 30

def data
  @data
end

#metadataObject (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

#hashObject



48
49
50
# File 'lib/bsv/network/result.rb', line 48

def hash
  [self.class, data, ].hash
end

#success?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/bsv/network/result.rb', line 38

def success?
  true
end