Class: Easy::Api::BlockWrapper::Wrapper
- Inherits:
-
Object
- Object
- Easy::Api::BlockWrapper::Wrapper
- Defined in:
- lib/easy/api/block_wrapper.rb
Overview
A class to encapulate the API code so it can be called from the block.
Instance Method Summary collapse
-
#initialize(controller) ⇒ Wrapper
constructor
A new instance of Wrapper.
-
#method_missing(name, *args, &block) ⇒ Object
Delegate other method calls to the result object.
-
#render_result(render_params) ⇒ Object
use the controller to render the response.
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
Delegate other method calls to the result object
36 37 38 |
# File 'lib/easy/api/block_wrapper.rb', line 36 def method_missing(name, *args, &block) @result.send(name, *args, &block) end |
Instance Method Details
#render_result(render_params) ⇒ Object
use the controller to render the response
26 27 28 29 30 31 32 33 |
# File 'lib/easy/api/block_wrapper.rb', line 26 def render_result(render_params) format = (render_params[:format] || 'json').try(:to_sym) if render_params[:callback].blank? @controller.render(format => @result, :status => @result.status_code) else @controller.render(format => @result, :status => @result.status_code, :callback => render_params[:callback], :content_type => 'application/javascript') end end |