Class: Peach::Stream::Response
- Inherits:
-
Object
- Object
- Peach::Stream::Response
- Defined in:
- lib/peach/stream/response.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
Instance Method Summary collapse
- #add_action(action, *args, **kwargs) ⇒ Object
- #body ⇒ Object
-
#initialize ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
10 11 12 |
# File 'lib/peach/stream/response.rb', line 10 def initialize @changes = [] end |
Instance Attribute Details
#changes ⇒ Object (readonly)
Returns the value of attribute changes.
8 9 10 |
# File 'lib/peach/stream/response.rb', line 8 def changes @changes end |
Instance Method Details
#add_action(action, *args, **kwargs) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/peach/stream/response.rb', line 14 def add_action(action, *args, **kwargs) raise Peach::BadResponseError, "Action '#{action}' is not supported" unless respond_to?(action, true) change = { action: action } change.merge! send(action, *args, **kwargs) @changes << change end |
#body ⇒ Object
22 23 24 25 |
# File 'lib/peach/stream/response.rb', line 22 def body body = { changes: changes } JSON.generate(body) end |