Module: HasManyTranslations::Options::ClassMethods
- Defined in:
- lib/has_many_translations/options.rb
Overview
Class methods that provide preparation of options passed to the has_translations
method.
Instance Method Summary collapse
-
#prepare_translated_options(options) ⇒ Object
The
prepare_has_translations_options
method has three purposes: 1.
Instance Method Details
#prepare_translated_options(options) ⇒ Object
The prepare_has_translations_options
method has three purposes:
-
Populate the provided options with default values where needed
-
Prepare options for use with the
has_many
association -
Save user-configurable options in a class-level variable
Options are given priority in the following order:
-
Those passed directly to the
translated
method -
Those specified in an initializer
configure
block -
Default values specified in
prepare_has_translations_options
The method is overridden in feature modules that require specific options outside the standard has_many
associations.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/has_many_translations/options.rb', line 26 def () .symbolize_keys! .reverse_merge!(Configuration.) .reverse_merge!( :class_name => 'HasManyTranslations::Translation', :dependent => :delete_all ) class_inheritable_accessor :has_many_translations_options class_inheritable_accessor :translator # self.translator = Translate::RTranslate.new if defined? HmtSettings ToLang.start(HmtSettings.google_api_key) # self.translator.key = HmtSettings.google_api_key [:default_languages] = HmtSettings.default_languages ? HmtSettings.default_languages : nil [:languages] = HmtSettings.languages ? HmtSettings.languages : nil # options[:force_on_update] = HmtSettings.force_on_update ? HmtSettings.force_on_update : nil end self. = .dup .merge!( :as => :translated, :extend => Array([:extend]).unshift(Translations) ) end |