Class: Cuprum::Rails::Result
- Inherits:
-
Cuprum::Result
- Object
- Cuprum::Result
- Cuprum::Rails::Result
- Defined in:
- lib/cuprum/rails/result.rb
Overview
Result class representing the result of calling an action.
In addition to the standard properties inherited from Cuprum::Result, each Cuprum::Rails::Result also includes a #metadata property. This represents secondary information about the result that may be relevant for rendering or displaying the data, but is not part of the requested value. For example. information about the current controller would be metadata, as would the current authentication session.
Instance Attribute Summary collapse
-
#metadata ⇒ Hash{Symbol => Object}
readonly
The request or action metadata.
Instance Method Summary collapse
-
#initialize(error: nil, metadata: {}, status: nil, value: nil) ⇒ Result
constructor
A new instance of Result.
-
#properties ⇒ Hash{Symbol => Object}
(also: #to_h)
A Hash representation of the result.
Constructor Details
#initialize(error: nil, metadata: {}, status: nil, value: nil) ⇒ Result
Returns a new instance of Result.
21 22 23 24 25 |
# File 'lib/cuprum/rails/result.rb', line 21 def initialize(error: nil, metadata: {}, status: nil, value: nil) super(error: error, status: status, value: value) @metadata = end |
Instance Attribute Details
#metadata ⇒ Hash{Symbol => Object} (readonly)
Returns the request or action metadata.
28 29 30 |
# File 'lib/cuprum/rails/result.rb', line 28 def @metadata end |
Instance Method Details
#properties ⇒ Hash{Symbol => Object} Also known as: to_h
Returns a Hash representation of the result.
31 32 33 |
# File 'lib/cuprum/rails/result.rb', line 31 def properties super().merge(metadata: ) end |