Class: Moonrope::ActionResult
- Inherits:
-
Object
- Object
- Moonrope::ActionResult
- Defined in:
- lib/moonrope/action_result.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
The return value from the action.
-
#flags ⇒ Hash
Flags which have been set in the action.
-
#headers ⇒ Hash
Headers which have been set in the action.
-
#status ⇒ String
The status of the request.
-
#time ⇒ Float
The length of time to process the action.
Instance Method Summary collapse
-
#initialize(action) ⇒ ActionResult
constructor
Initialize a new result from a Moonrope::Action.
-
#to_hash ⇒ Hash
Return a Hash representation of this ActionResult without the headers.
-
#to_json ⇒ String
Return the ActionResult’s hash with a JSON.
Constructor Details
#initialize(action) ⇒ ActionResult
Initialize a new result from a Moonrope::Action.
9 10 11 12 13 14 |
# File 'lib/moonrope/action_result.rb', line 9 def initialize(action) @action = action @headers = {} @time = nil @flags = {} end |
Instance Attribute Details
#data ⇒ Object
Returns the return value from the action.
17 18 19 |
# File 'lib/moonrope/action_result.rb', line 17 def data @data end |
#flags ⇒ Hash
Returns flags which have been set in the action.
29 30 31 |
# File 'lib/moonrope/action_result.rb', line 29 def flags @flags end |
#headers ⇒ Hash
Returns headers which have been set in the action.
23 24 25 |
# File 'lib/moonrope/action_result.rb', line 23 def headers @headers end |
#status ⇒ String
Returns the status of the request.
20 21 22 |
# File 'lib/moonrope/action_result.rb', line 20 def status @status end |
#time ⇒ Float
Returns the length of time to process the action.
26 27 28 |
# File 'lib/moonrope/action_result.rb', line 26 def time @time end |
Instance Method Details
#to_hash ⇒ Hash
Return a Hash representation of this ActionResult without the headers.
{
:status => 'success',
:time => 1.32,
:flags => {},
:data => {}
}
44 45 46 47 48 49 50 51 |
# File 'lib/moonrope/action_result.rb', line 44 def to_hash { :status => self.status, :time => self.time, :flags => self.flags, :data => self.data } end |
#to_json ⇒ String
Return the ActionResult’s hash with a JSON.
58 59 60 |
# File 'lib/moonrope/action_result.rb', line 58 def to_json to_hash.to_json end |