Sha256: bdf5cf990876920ccabbe84e99cfe26833414d422ac4654aa3663d07b433a055
Contents?: true
Size: 1.08 KB
Versions: 16
Compression:
Stored size: 1.08 KB
Contents
module Hoth class Service attr_accessor :name, :params_arity, :module def initialize(name, &block) @name = name @params_arity = block.arity instance_eval(&block) end def returns(return_value) @return_value = return_value end def transport @transport ||= Transport.create(endpoint.transport, self) end def impl_class @impl_class_name ||= "#{self.name.to_s.camelize}Impl" begin @impl_class_name.constantize rescue NameError => e # no local implementation false end end def is_local? !!impl_class end def execute(*args) result = self.is_local? ? impl_class.send(:execute, *args) : transport.call_remote_with(*args) return return_nothing? ? nil : result end def return_nothing? [:nothing, :nil, nil].include? @return_value end def via_endpoint(via = nil) @via_endpoint = via || :default end def endpoint @endpoint ||= self.module[Hoth.env][@via_endpoint] end end end
Version data entries
16 entries across 16 versions & 2 rubygems