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
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
Public Instance Methods
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
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
Broad equality.
# File lib/ae/core_ext/helpers.rb, line 53 def equate?(x) equal?(x) || eql?(x) || self == x || self === x end
Is literally false.
# File lib/ae/core_ext/helpers.rb, line 13 def false? FalseClass === self end
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
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
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
# 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
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
Is literally true.
# File lib/ae/core_ext/helpers.rb, line 8 def true? TrueClass === self end