module Statics::Translatable::ClassMethods
Public Instance Methods
override_translatable_attribute_getter(name)
click to toggle source
# 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 = {})
click to toggle source
# File lib/statics/translatable.rb, line 14 def translatable_attribute(name, options = {}) attribute(name, Types::Translations.meta(omittable: options.fetch(:optional, false))) override_translatable_attribute_getter(name) end
translatable_attributes(*names, **options)
click to toggle source
# File lib/statics/translatable.rb, line 10 def translatable_attributes(*names, **options) names.each { |name| translatable_attribute(name, options) } end