module StrongDelegate
Constants
- VERSION
Public Class Methods
included(base)
click to toggle source
# File lib/strong_delegate.rb, line 6 def self.included(base) base.extend(ClassMethods) end
Private Instance Methods
assert_delegate!(object, name)
click to toggle source
# File lib/strong_delegate.rb, line 60 def assert_delegate!(object, name) return if object.method(name).parameters.map(&:first) == self.class.delegate_methods[name].map(&:first) raise StrongDelegate::InvalidInterfaceError end
delegate_object()
click to toggle source
# File lib/strong_delegate.rb, line 49 def delegate_object instance_variable_get self.class.delegate_variable_name end
invoke_delegate_method!(name, args, block)
click to toggle source
# File lib/strong_delegate.rb, line 53 def invoke_delegate_method!(name, args, block) object = delegate_object assert_delegate!(object, name.to_sym) object.public_send(name, *args, &block) end
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/strong_delegate.rb, line 41 def method_missing(name, *args, &block) if self.class.delegate_methods.key?(name.to_sym) invoke_delegate_method!(name.to_sym, args, block) else super end end