Module: TranslationAttribute

Defined in:
lib/attr_translate/translation_attribute.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, **params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/attr_translate/translation_attribute.rb', line 7

def method_missing(method_name, *args, **params)
  translated_attr_name, locale, assigning = parse_translated_attribute_accessor(method_name)

  return super(method_name, *args, **params) unless translated_attr_name

  if assigning
    write_json_translation(translated_attr_name, args.first, locale)
  else
    read_json_translation(translated_attr_name, locale, **params)
  end
end

Instance Method Details

#respond_to?(symbol, include_all = false) ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
5
# File 'lib/attr_translate/translation_attribute.rb', line 2

def respond_to?(symbol, include_all = false)
  return true if parse_translated_attribute_accessor(symbol)
  super(symbol, include_all)
end