Class: Insider

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n_translator.rb

Class Method Summary collapse

Class Method Details

.original_method(method) ⇒ Object



20
21
22
# File 'lib/i18n_translator.rb', line 20

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

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



8
9
10
11
12
13
# File 'lib/i18n_translator.rb', line 8

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



15
16
17
18
# File 'lib/i18n_translator.rb', line 15

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