Module: Dizby::PolymorphicDelegated::InstanceMethods

Defined in:
lib/dizby/utility/polymorphic_delegated.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block)



54
55
56
57
58
# File 'lib/dizby/utility/polymorphic_delegated.rb', line 54

def method_missing(name, *args, &block)
  args.unshift(self) if args.empty? || !args.first.is_a?(Delegator)

  __delegate__ name, *args, &block
end

Instance Method Details

#__delegate__(name, delegator, *args, &block)



46
47
48
49
50
51
52
# File 'lib/dizby/utility/polymorphic_delegated.rb', line 46

def __delegate__(name, delegator, *args, &block)
  unbound = self.class.__delegated_methods__[name]

  bound = Dizby.force_bind(delegator, unbound)

  bound.call(*args, &block)
end

#respond_to?(sym, _priv = false) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/dizby/utility/polymorphic_delegated.rb', line 60

def respond_to?(sym, _priv = false)
  super || self.class.__delegated_methods__.keys.include?(sym)
end