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)
50
51
52
53
54
|
# File 'lib/dizby/utility/polymorphic_delegated.rb', line 50
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)
42
43
44
45
46
47
48
|
# File 'lib/dizby/utility/polymorphic_delegated.rb', line 42
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
56
57
58
|
# File 'lib/dizby/utility/polymorphic_delegated.rb', line 56
def respond_to?(sym, _priv = false)
super || self.class.__delegated_methods__.keys.include?(sym)
end
|