Class: App::Command::Result
- Inherits:
-
Struct
- Object
- Struct
- App::Command::Result
- Defined in:
- lib/has_helpers/app/command.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#exception ⇒ Object
Returns the value of attribute exception.
-
#explicit_value ⇒ Object
Returns the value of attribute explicit_value.
-
#explicit_value_is_set ⇒ Object
Returns the value of attribute explicit_value_is_set.
-
#failed ⇒ Object
Returns the value of attribute failed.
Instance Method Summary collapse
- #fail(msg = nil) ⇒ Object
- #fail!(msg = nil) ⇒ Object
-
#initialize(**attrs) ⇒ Result
constructor
Accept Hash values for attributes.
- #value ⇒ Object
- #value=(v) ⇒ Object
Constructor Details
#initialize(**attrs) ⇒ Result
Accept Hash values for attributes.
Result.new(error: "Something bad happened") # => #
16 17 18 19 20 |
# File 'lib/has_helpers/app/command.rb', line 16 def initialize(**attrs) unknown_attrs = attrs.keys - self.class.members raise ::ArgumentError, "Unknown struct member#{ unknown_attrs.length == 1 ? "" : "s" }: #{ unknown_attrs.map(&:inspect).join(", ") }" unless unknown_attrs.empty? super(*attrs.values_at(*self.class.members)) end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error
10 11 12 |
# File 'lib/has_helpers/app/command.rb', line 10 def error @error end |
#exception ⇒ Object
Returns the value of attribute exception
10 11 12 |
# File 'lib/has_helpers/app/command.rb', line 10 def exception @exception end |
#explicit_value ⇒ Object
Returns the value of attribute explicit_value
10 11 12 |
# File 'lib/has_helpers/app/command.rb', line 10 def explicit_value @explicit_value end |
#explicit_value_is_set ⇒ Object
Returns the value of attribute explicit_value_is_set.
11 12 13 |
# File 'lib/has_helpers/app/command.rb', line 11 def explicit_value_is_set @explicit_value_is_set end |
#failed ⇒ Object
Returns the value of attribute failed.
11 12 13 |
# File 'lib/has_helpers/app/command.rb', line 11 def failed @failed end |
Instance Method Details
#fail(msg = nil) ⇒ Object
22 23 24 25 |
# File 'lib/has_helpers/app/command.rb', line 22 def fail(msg = nil) self.failed = true self.error ||= msg end |
#fail!(msg = nil) ⇒ Object
27 28 29 30 |
# File 'lib/has_helpers/app/command.rb', line 27 def fail!(msg = nil) fail(msg) raise FailureError, error end |
#value ⇒ Object
37 38 39 |
# File 'lib/has_helpers/app/command.rb', line 37 def value explicit_value end |
#value=(v) ⇒ Object
32 33 34 35 |
# File 'lib/has_helpers/app/command.rb', line 32 def value=(v) self.explicit_value_is_set = true self.explicit_value = v end |