Class: Lookout::Aphonic

Inherits:
Object show all
Defined in:
lib/lookout-3.0/aphonic.rb

Overview

Class that only responds to ‘#__send__` and #object_id. Useful for DSLs and classes that make use of #method_missing. Things are set up so that if methods are added to Kernel, Object, or Method after the initial set-up, such methods will similarly be Aphonic.silenced.

Direct Known Subclasses

Actual, Object::Not::Receive, Object::To::Receive

Constant Summary collapse

Methods =
[:__send__, :object_id]

Class Method Summary collapse

Class Method Details

.silence(method) ⇒ self

Undefines METHOD unless it’s on the short-list of methods to keep.

Parameters:

Returns:

  • (self)


15
16
17
18
19
20
# File 'lib/lookout-3.0/aphonic.rb', line 15

def silence(method)
  undef_method method if
    instance_methods.include?(RUBY_VERSION < '1.9' ? method.to_s : method.to_sym) and
    not Methods.include? method.to_sym
  self
end