Sha256: 4d43027de9737580790b1dcf818091b942eb95f38b0191b72b9584c97d991f60

Contents?: true

Size: 628 Bytes

Versions: 1

Compression:

Stored size: 628 Bytes

Contents

require "metaclass"

module Introspection

  module Receivers

    class NullMetaclass
      def ancestors
        Array.new
      end
    end

    class NullReceiver
      def __metaclass__
        NullMetaclass.new
      end

      def receivers
        Array.new
      end
    end

    def superklass
      respond_to?(:superclass) ? superclass : NullReceiver.new
    end

    def local_receivers
      [__metaclass__] + __metaclass__.ancestors - superklass.__metaclass__.ancestors
    end

    def receivers
      local_receivers + superklass.receivers
    end

  end
end

class Object
  include Introspection::Receivers
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
introspection-0.0.2 lib/introspection/receivers.rb