class QRPC::Protocol::Abstract

Abstract protocol implementation.

@since 0.9.0 @abstract

Abstract protocol implementation. @since 0.9.0

Abstract protocol implementation. @since 0.9.0

Abstract protocol implementation. @since 0.9.0

Abstract protocol implementation. @since 0.9.0

Attributes

options[RW]

Holds general object options. @return [Hashie::Mash] general options

Public Class Methods

new(options = { }) click to toggle source

Constructor.

@param [Hash] options general options for submodules @abstract

# File lib/qrpc/protocol/abstract.rb, line 53
def initialize(options = { })
    @options = Hashie::Mash::new(options)
    @module_cache = { }
    
    if self.instance_of? Abstract
        not_implemented
    end
end

Public Instance Methods

error() click to toggle source

Returns new error object. @return [Class] class of the error object

# File lib/qrpc/protocol/abstract.rb, line 85
def error
    __module(:Error)
end
request() click to toggle source

Returns new request object. @return [Class] class of the request object

# File lib/qrpc/protocol/abstract.rb, line 67
def request
    __module(:Request)
end
response() click to toggle source

Returns new response object. @return [Class] class of the response object

# File lib/qrpc/protocol/abstract.rb, line 76
def response
    __module(:Response)
end

Private Instance Methods

__module(name) click to toggle source

Returns class from module according to specific driver

Calls superclass method
# File lib/qrpc/protocol/abstract.rb, line 94
def __module(name)
    mod = Module.get_module(self.class.name + "::" + name.to_s)
    
    if not mod.in? @module_cache
        cls = Class::new(mod)
        opt = @options
        
        cls.class_eval do
            define_method :initialize do |options = { }, &block|
                super(opt.merge(options), &block)
            end
            
            define_singleton_method :options do 
                opt
            end
        end

        @module_cache[mod] = cls                    
    end
        
    @module_cache[mod]
end