Class: AppBaseController::RpcMethodStubHelper
- Inherits:
-
Object
- Object
- AppBaseController::RpcMethodStubHelper
- Defined in:
- lib/appbase/controllers/app_base_controller.rb
Instance Method Summary collapse
- #add_stub(controller) ⇒ Object
-
#initialize(bound_method, auth = false) ⇒ RpcMethodStubHelper
constructor
A new instance of RpcMethodStubHelper.
Constructor Details
#initialize(bound_method, auth = false) ⇒ RpcMethodStubHelper
Returns a new instance of RpcMethodStubHelper.
147 148 149 150 151 152 153 |
# File 'lib/appbase/controllers/app_base_controller.rb', line 147 def initialize(bound_method, auth=false) @bound_method = bound_method @auth = auth @method_name = bound_method.name @model_name = bound_method.receiver.name.to_s.extend(AppBase::StringExtension) init end |
Instance Method Details
#add_stub(controller) ⇒ Object
155 156 157 158 159 160 161 162 163 164 |
# File 'lib/appbase/controllers/app_base_controller.rb', line 155 def add_stub(controller) controller.class_eval %- def rpc_#{@model_name.underscore}_#{@method_name} #{@requires.map{|p|"params.require #{p}"}.join(';')} render json: { status: 'ok', data: #{@model_name}.#{@method_name}(#{@parameters.join(', ')}) } rescue Exception => e render json: { status: 'error', msg: e.to_s } end - end |