Class: Writ::Outcome

Inherits:
Object
  • Object
show all
Defined in:
lib/writ.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, writ) ⇒ Outcome

Public: Initialize the outcome.

value - The return value from Writ.run writ - The Writ instance.



44
45
46
47
48
# File 'lib/writ.rb', line 44

def initialize(value, writ)
  @value = value
  @input = writ
  @errors = writ.errors
end

Instance Attribute Details

#errorsObject (readonly)

Public: Get the errors Hash generated by running Writ.run. This will be an empty Hash if no errors were returned.



38
39
40
# File 'lib/writ.rb', line 38

def errors
  @errors
end

#inputObject (readonly)

Public: Get the Writ object, with the user input as accessors.



34
35
36
# File 'lib/writ.rb', line 34

def input
  @input
end

#valueObject (readonly)

Public: Get the return value of your Writ.



31
32
33
# File 'lib/writ.rb', line 31

def value
  @value
end

Instance Method Details

#success?Boolean

Public: Whether the Writ performed successfully or not (i.e. no errors are present.)

Returns Boolean.

Returns:

  • (Boolean)


54
55
56
# File 'lib/writ.rb', line 54

def success?
  errors.empty?
end