Module: Statics::Translatable::ClassMethods
- Defined in:
- lib/statics/translatable.rb
Instance Method Summary collapse
- #override_translatable_attribute_getter(name) ⇒ Object
- #translatable_attribute(name, options = {}) ⇒ Object
- #translatable_attributes(*names, **options) ⇒ Object
Instance Method Details
#override_translatable_attribute_getter(name) ⇒ Object
19 20 21 22 23 |
# File 'lib/statics/translatable.rb', line 19 def override_translatable_attribute_getter(name) define_method(name) do |locale: I18n.locale| attributes.dig(name, locale.to_sym) end end |
#translatable_attribute(name, options = {}) ⇒ Object
14 15 16 17 |
# File 'lib/statics/translatable.rb', line 14 def translatable_attribute(name, = {}) attribute(name, Types::Translations.(omittable: .fetch(:optional, false))) override_translatable_attribute_getter(name) end |
#translatable_attributes(*names, **options) ⇒ Object
10 11 12 |
# File 'lib/statics/translatable.rb', line 10 def translatable_attributes(*names, **) names.each { |name| translatable_attribute(name, ) } end |