Class: Gizmo::BaseOperation
- Inherits:
-
Object
- Object
- Gizmo::BaseOperation
- Defined in:
- lib/gizmo/base_operation.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #create_response ⇒ Object
- #default_status ⇒ Object
-
#initialize(context) ⇒ BaseOperation
constructor
Creates a new Find and sets its context.
-
#set_response_headers(gizmo_response) ⇒ Object
Set headers on the response.
Constructor Details
#initialize(context) ⇒ BaseOperation
Creates a new Find and sets its context
9 10 11 |
# File 'lib/gizmo/base_operation.rb', line 9 def initialize(context) @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/gizmo/base_operation.rb', line 4 def context @context end |
Instance Method Details
#create_response ⇒ Object
13 14 15 |
# File 'lib/gizmo/base_operation.rb', line 13 def create_response Response.new(format: context.format, callback: context.callback, status: default_status) end |
#default_status ⇒ Object
17 18 19 |
# File 'lib/gizmo/base_operation.rb', line 17 def default_status 200 end |
#set_response_headers(gizmo_response) ⇒ Object
Set headers on the response
24 25 26 27 28 29 30 |
# File 'lib/gizmo/base_operation.rb', line 24 def set_response_headers(gizmo_response) if context.gizmo.respond_to?(:headers) && gizmo_response.headers gizmo_response.headers.each do |name, value| context.gizmo.headers[name] = value end end end |