Module: Rails::Translate::ActsMethods::ClassMethods

Defined in:
lib/rails-translate.rb

Overview

translate

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rails-translate.rb', line 37

def method_missing(method, *args)
  if method.to_s =~ /^find_(all_by|by)_([_a-zA-Z]\w*)$/
    if column_methods_hash.include?($2.to_sym)
      super
    else
      modifier = $1
      attribute = "#{$2}_#{I18n.locale.to_s}"
      send("find_#{modifier}_#{attribute}".to_sym, *args)
    end
  else
    super
  end
end