vendor/bundle/ruby/1.8/gems/emissary-1.3.18/lib/emissary/identity.rb
# Delegation Factory - Uses registered high priority subclasses 
# for delegation of method calls, falling back to lower priority 
# subclasess when the method isn't available or throws a :pass
# in the higher priority subclass
#
Delegation Factory - Uses registered high priority subclasses
for delegation of method calls, falling back to lower priority
subclasess when the method isn't available or throws a :pass
in the higher priority subclass
Delegation Factory - Uses registered high priority subclasses for delegation of method calls falling back to lower priority subclasess when the method isn ' t available or throws a : pass in the higher priority subclass
def method_missing name, *args
      super name, *args unless self.class == Emissary::Identity
      name = name.to_sym
      unless (@methods||={}).has_key? name
        method_delegate = value = nil
        identities.each do |id,object|
          value = nil
          if object.respond_to?(name)
            method_delegate = catch(:pass) {
              value = object.__send__(name, *args) 
              object
            }
            break unless method_delegate.nil?
          end
        end
        if method_delegate.nil?
          return super(name, *args)
        end
        @methods[name] = method_delegate
        return value
      end
      return @methods[name].__send__(name, *args)
    end
def method_missing name , * args super name , * args unless self . class == Emissary :: Identity name = name . to_sym unless ( @methods ||= { } ) . has_key? name method_delegate = value = nil identities . each do | id , object | value = nil if object . respond_to? ( name ) method_delegate = catch ( :pass ) { value = object . __send__ ( name , * args ) object } break unless method_delegate . nil? end end if method_delegate . nil? return super ( name , * args ) end @methods [ name ] = method_delegate return value end return @methods [ name ] . __send__ ( name , * args ) end
Delegation Factory - Uses registered high priority subclasses
for delegation of method calls, falling back to lower priority
subclasess when the method isn't available or throws a :pass
in the higher priority subclass
Delegation Factory - Uses registered high priority subclasses for delegation of method calls falling back to lower priority subclasess when the method isn ' t available or throws a : pass in the higher priority subclass
# don't perform lookups on subclasses # loop through each possible identity, higher priority identities # first (0 == low, > 0 == higher).  # test for :pass request # if we've gone through all the possible delegates, then pass it # up to the superclass (in this case, Object)
name
args