module Kernel

Since Ruby is very dynamic, methods added to the ancestors of BlankSlate after BlankSlate is defined will show up in the list of available BlankSlate methods. We handle this by defining a hook in the Object and Kernel classes that will hide any method defined after BlankSlate has been loaded.

Public Class Methods

basic_object_method_added(name)
Alias for: method_added
method_added(name) click to toggle source

Detect method additions to Kernel and remove them in the BasicObject class.

# File lib/ae/basic_object.rb, line 63
def method_added(name)
  result = basic_object_method_added(name)
  return result if self != Kernel
  AE::BasicObject.hide(name)
  result
end
Also aliased as: basic_object_method_added

Public Instance Methods

case?(value=NoArgument) { || ... } click to toggle source

Word form of ===. Also can take a block.

# File lib/ae/core_ext/helpers.rb, line 35
def case?(value=NoArgument) #:yield:
  if block_given?
    self === yield
  else
    self === value
  end
end
eq?(value=NoArgument) { || ... } click to toggle source

Word form of #==. Also can take a block.

# File lib/ae/core_ext/helpers.rb, line 26
def eq?(value=NoArgument) #:yield:
  if block_given?
    self == yield
  else
    self == value
  end
end
equate?(x) click to toggle source

Broad equality.

# File lib/ae/core_ext/helpers.rb, line 53
def equate?(x)
  equal?(x) || eql?(x) || self == x || self === x
end
false?() click to toggle source

Is literally false.

# File lib/ae/core_ext/helpers.rb, line 13
def false?
  FalseClass === self
end
identical?(exp) click to toggle source

Are identical, eg. object_id's are equal.

# File lib/ae/core_ext/helpers.rb, line 18
def identical?(exp)
  exp.object_id == object_id
end
Also aliased as: identical_to?
identical_to?(exp)

Alias for identical?

Alias for: identical?
match?(value=NoArgument) { || ... } click to toggle source

Word form for #=~. Also can take a block.

# File lib/ae/core_ext/helpers.rb, line 44
def match?(value=NoArgument)
  if block_given?
    self =~ yield
  else
    self =~ value
  end
end
pry() click to toggle source

Pry allows you to test private and protected methods thru a public-only interface.

Generally one should avoid testing private and protected methods directly, instead relying on tests of public methods to indirectly test them, because private and protected methods are considered implementation details. But sometimes it is necessary to test them directly, or if you wish to achieve *absolute coverage*, say in a mission critical system.

@return [Pry] pry functor

# File lib/ae/pry.rb, line 21
def pry
  $PRY_TABLE[self] ||= Pry.new do |op, *a, &b|
    __send__(op, *a, &b)
  end
end
public_send(m,*a,&b) click to toggle source
# File lib/ae/core_ext/helpers.rb, line 74
def public_send(m,*a,&b)
  raise NoMethodError unless respond_to?(m)
  __send__(m,*a,&b)
end
send?(method, *args, &block) click to toggle source

Can a message be sent to the receiver successfully?

# File lib/ae/core_ext/helpers.rb, line 58
def send?(method, *args, &block)
  begin
    __send__(method, *args, &block)
    true
  rescue NoMethodError
    false
  end
end
true?() click to toggle source

Is literally true.

# File lib/ae/core_ext/helpers.rb, line 8
def true?
  TrueClass === self
end