Module: Psychanalyst

Defined in:
lib/without_instanciation.rb

Class Method Summary collapse

Class Method Details

.original_method(method) ⇒ Object



31
32
33
# File 'lib/without_instanciation.rb', line 31

def self.original_method method
  ('original_' + method.to_s).to_sym
end

.redefine(klass, method, &block) ⇒ Object



19
20
21
22
23
24
# File 'lib/without_instanciation.rb', line 19

def self.redefine klass, method, &block
  klass.send(:alias_method, original_method(method), method)
  klass.send(:define_method, method) do |*params|
    instance_exec(*params, &block)
  end
end

.undefine(klass, method) ⇒ Object



26
27
28
29
# File 'lib/without_instanciation.rb', line 26

def self.undefine klass, method
  klass.send(:undef_method, method)
  klass.send(:alias_method, method, original_method(method))
end