lib/universa/service.rb in universa-3.11.4.4 vs lib/universa/service.rb in universa-3.12.0.2
- old
+ new
@@ -23,11 +23,11 @@
def initialize
@config = SmartHash.new path: nil
@@log_umi && @config['log'] = 'umi.log'
@known_proxies = {}
[Contract, PrivateKey, PublicKey, KeyAddress, HashId, Binder,
- Role, SimpleRole, RoleLink, ListRole,
+ Role, SimpleRole, RoleLink, ListRole, Parcel, UnsContract,
ChangeOwnerPermission, RevokePermission, ModifyDataPermission, SplitJoinPermission,
UmiClient, Duration, Compound, KeyInfo, PBKDF2].each {|klass| register_proxy klass}
end
# Implementation of {Service.configure}
@@ -47,11 +47,11 @@
# push string to service log
def log msg
puts "U:Service: #{msg}"
end
- # Create objectproxy for known types
+ # Create object proxy for known types
# @param [Ref] ref to transform
# @return [RemoteAdapter | Ref] transformed or source reference
def create_proxy ref
proxy_class = @known_proxies[ref._remote_class_name]
return ref unless proxy_class
@@ -71,12 +71,15 @@
def umi
instance.umi
end
end
- private
-
- def register_proxy klass
+ # Register a class that will work as a proxy for UMI remote class. Such adapter class mist extend RemoteAdapter
+ # class. Once the class is registered, serive will automatically instantiate it when UMI will pass the instance
+ # of the corresponding remote class.
+ # @param [Class] klass that will be
+ def register_proxy(klass)
+ RemoteAdapter > klass or raise ArgumentError, "#{klass.name} must be based on RemoteAdapter"
remote_class_name = klass.remote_class_name
raise Error, "#{remote_class_name} is already registered in Service" if @known_proxies.include?(remote_class_name)
@known_proxies[remote_class_name] = klass
end
end