class AppBase::Engine::RpcMethodInitializer

Public Class Methods

new(config) click to toggle source
# File lib/appbase/railtie.rb, line 16
def initialize(config)
  @model = config[:model]
  @method = config[:method]
  @auth = config[:auth]
end

Public Instance Methods

init() click to toggle source
# File lib/appbase/railtie.rb, line 22
def init
  pre_init
  add_controller_stub
  add_route
end

Private Instance Methods

add_controller_stub() click to toggle source
# File lib/appbase/railtie.rb, line 36
def add_controller_stub
  bound_method = @model.method @method
  AppBaseController.add_rpc_method_stub(bound_method, @auth)
end
add_route() click to toggle source
# File lib/appbase/railtie.rb, line 41
def add_route
  model_name_underscore = AppBase.underscore @model.name
  method_name = @method
  AppBase::Engine.routes.append do
    post "/#{model_name_underscore}/#{method_name}" => "app_base#rpc_#{model_name_underscore}_#{method_name}"
  end
end
pre_init() click to toggle source
# File lib/appbase/railtie.rb, line 29
def pre_init
  model_name = @model.name
  if !@model.respond_to?(@method)
    raise "#{model_name} does not respond to #{@method}."
  end
end