Class: JsendWrapper::SuccessRenderer
- Defined in:
- lib/jsend_wrapper/renderers/success_renderer.rb
Overview
Wraps the given message in a JSend Success. JSend Successes have two required elements (status, data).
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(data) ⇒ SuccessRenderer
constructor
A new instance of SuccessRenderer.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(data) ⇒ SuccessRenderer
Returns a new instance of SuccessRenderer.
24 25 26 |
# File 'lib/jsend_wrapper/renderers/success_renderer.rb', line 24 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
22 23 24 |
# File 'lib/jsend_wrapper/renderers/success_renderer.rb', line 22 def data @data end |
Instance Method Details
#to_h ⇒ Object
32 33 34 |
# File 'lib/jsend_wrapper/renderers/success_renderer.rb', line 32 def to_h { status: 'success', data: data } end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/jsend_wrapper/renderers/success_renderer.rb', line 28 def to_s %[{"status":"success","data":#{json_string data}}] end |