module Upcastable::Hooks

Public Class Methods

extended(base) click to toggle source
# File lib/upcastable/hooks.rb, line 3
def self.extended(base)
  if base < Object
    raise ArgumentError, 'extended class or module must be an ancestor of Object'
  end

  base.class_eval do
    class << self
      alias_method :__upcastable_orig_method_added, :method_added

      private

        def method_added(name)
          return unless Object <= self
          ::Upcastable::UpcastedObject.define_delegate_method(name)
          __upcastable_orig_method_added(name)
        end
    end
  end
end

Private Class Methods

__upcastable_orig_method_added(name)
Alias for: method_added
method_added(name) click to toggle source
# File lib/upcastable/hooks.rb, line 14
def method_added(name)
  return unless Object <= self
  ::Upcastable::UpcastedObject.define_delegate_method(name)
  __upcastable_orig_method_added(name)
end