Sha256: 4aa7a853b928d927cca7e558bd55833404d451c3e122530952fbcb71f346c996

Contents?: true

Size: 930 Bytes

Versions: 10

Compression:

Stored size: 930 Bytes

Contents

class Module

  # List all instance methods, equivalent to
  #
  #   public_instance_methods +
  #   protected_instance_methods +
  #   private_instance_methods
  #
  # TODO: Better name for #all_instance_methods?
  #
  # CREDIT: Trans

  def all_instance_methods(include_super=true)
    public_instance_methods(include_super) +
    protected_instance_methods(include_super) +
    private_instance_methods(include_super)
  end

  # Query whether a public instance method is defined for the module.
  #
  # CREDIT: Gavin Sinclair, Noah Gibbs

  def instance_method_defined?(meth)
    instance_methods(true).find{ |m| m == meth.to_s }
  end

  # Query whether a normal (singleton) method is defined for the module.
  #
  # CREDIT: Gavin Sinclair, Noah Gibbs

  def singleton_method_defined?(meth)
    singleton_methods(true).find{ |m| m == meth.to_s }
  end

  alias_method :module_method_defined?, :singleton_method_defined?

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/module/instance_methods.rb
facets-2.8.3 lib/core/facets/module/instance_methods.rb
facets-2.8.2 lib/core/facets/module/instance_methods.rb
facets-2.8.1 lib/core/facets/module/instance_methods.rb
facets-2.8.0 lib/core/facets/module/instance_methods.rb
facets-2.7.0 lib/core/facets/module/instance_methods.rb
facets-2.6.0 lib/core/facets/module/instance_methods.rb
facets-2.5.0 lib/core/facets/module/instance_methods.rb
facets-2.5.1 lib/core/facets/module/instance_methods.rb
facets-2.5.2 lib/core/facets/module/instance_methods.rb