Module: Modelish::PropertyTranslations::ClassMethods
- Defined in:
- lib/modelish/property_translations.rb
Overview
Methods for managing a dictionary of property translations
Instance Method Summary collapse
-
#add_property_translation(from_name, to_name) ⇒ Object
Adds a property translation to the model.
-
#translations ⇒ Hash<Symbol,Array>
A map of the configured property translations, keyed on from_name.
Instance Method Details
#add_property_translation(from_name, to_name) ⇒ Object
Adds a property translation to the model. This maps a mutator name to an existing property, so that whenever the from_name mutator is called on the model, the to_name property receives the value. If subsequent method calls add more destinations for the same source from_name, all destination properties will be updated.
63 64 65 66 67 68 69 70 |
# File 'lib/modelish/property_translations.rb', line 63 def add_property_translation(from_name, to_name) source = from_name.to_sym target = to_name.to_sym translations[source] ||= [] translations[source] << target define_writer_with_translations(source) end |
#translations ⇒ Hash<Symbol,Array>
A map of the configured property translations, keyed on from_name
75 76 77 |
# File 'lib/modelish/property_translations.rb', line 75 def translations @translations ||= {} end |