Sha256: c14c1e10876e6b5ebc469e1f0c5d6e9c622a8da6c6f537bba4e06f229ff17787

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

class Module
  if RUBY_VERSION > '1.9.1'
    alias reflexive_public_instance_methods public_instance_methods
    alias reflexive_private_instance_methods private_instance_methods
    alias reflexive_protected_instance_methods protected_instance_methods
  else
    # Try to workaround 1.9.1 *_instance_methods issues
    def reflexive_public_instance_methods(inc_super = true)
      if inc_super
        public_instance_methods(true)
      else
        methods = public_instance_methods(false)
        methods -= Module.public_instance_methods(false) unless self === Module
        methods -= Class.public_instance_methods(false) unless self === Class
#        ancestors.each do |ancestor|
#          methods -= ancestor.public_instance_methods(false)
#        end
        methods
      end
    end

    def reflexive_protected_instance_methods(inc_super = true)
      if inc_super
        protected_instance_methods(true)
      else
        methods = protected_instance_methods(false)
        methods -= Module.protected_instance_methods(false) unless self === Module
        methods -= Class.protected_instance_methods(false) unless self === Class
        methods
      end
    end

    def reflexive_private_instance_methods(inc_super = true)
      if inc_super
        private_instance_methods(true)
      else
        methods = private_instance_methods(false)
        methods -= Module.private_instance_methods(false) unless self === Module
        methods -= Class.private_instance_methods(false) unless self === Class
        methods
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reflexive-0.1.2 lib/reflexive/core_ext/module/reflexive_instance_methods.rb
reflexive-0.1.1 lib/reflexive/core_ext/module/reflexive_instance_methods.rb
reflexive-0.1.0 lib/reflexive/core_ext/module/reflexive_instance_methods.rb