-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Labels
Description
I propose adding the following to the README and implementing the adapter described:
RPC Adapter
An RPC Adapter is responsible for gathering the attributes from your model and marshalling them to the RPC call. Marshalling behaviors can be injected or modified at this point. The default RPC adapter is ::ActiveRemote::RPCAdapters::ProtobufAdapter.
You can, of course override it if need be:
# If you have a custom rpc adapter to use globally:
::ActiveRemote::RPC.default_adapter = ::MyCustom::RPCAdapter
# If you have a custom rpc adapter for an individual class:
class Product < ActiveRemote::Base
rpc_adapter ::MyCustom::RPCAdapter
end
# If you have a custom rpc adapter that has special setup needs:
class Product < ActiveRemote::Base
rpc_adapter :build_custom_rpc_adapter
private
def build_custom_rpc_adapter(model)
::MyCustom::RPCAdapter.new(@rpc_settings)
end
end
# Or, with a block
class Product < ActiveRemote::Base
rpc_adapter do |model|
::MyCustom::RPCAdapter.new(model.rpc_settings)
end
end