Class: Honeymaker::Result
- Inherits:
-
Object
- Object
- Honeymaker::Result
show all
- Defined in:
- lib/honeymaker/result.rb
Defined Under Namespace
Classes: Failure, Success
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data:, errors:) ⇒ Result
Returns a new instance of Result.
7
8
9
10
|
# File 'lib/honeymaker/result.rb', line 7
def initialize(data:, errors:)
@data = data
@errors = errors
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
5
6
7
|
# File 'lib/honeymaker/result.rb', line 5
def data
@data
end
|
#errors ⇒ Object
Returns the value of attribute errors.
5
6
7
|
# File 'lib/honeymaker/result.rb', line 5
def errors
@errors
end
|
Instance Method Details
#==(other) ⇒ Object
26
27
28
29
30
|
# File 'lib/honeymaker/result.rb', line 26
def ==(other)
return false unless other.is_a?(Result)
data == other.data && errors == other.errors
end
|
#failure? ⇒ Boolean
16
17
18
|
# File 'lib/honeymaker/result.rb', line 16
def failure?
!success?
end
|
#or(other) ⇒ Object
20
21
22
23
24
|
# File 'lib/honeymaker/result.rb', line 20
def or(other)
return data if success?
other
end
|
#success? ⇒ Boolean
12
13
14
|
# File 'lib/honeymaker/result.rb', line 12
def success?
errors.empty?
end
|