Sha256: b6abbf9aaa4c9416c5879cbd5a0e0234f2957524a357378d0d27063f6b3ed20d
Contents?: true
Size: 1.29 KB
Versions: 31
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true module Mobility module Backends =begin Defines read and write methods that access the value at a key with value +locale+ on a +translations+ hash. =end module HashValued # @!method column_affix # Returns interpolation string used to generate column names. # @return [String] Affix to generate column names # @!group Backend Accessors # # @!macro backend_reader def read(locale, _options = nil) translations[locale] end # @!macro backend_writer def write(locale, value, _options = nil) translations[locale] = value end # @!endgroup # @!macro backend_iterator def each_locale translations.each { |l, _| yield l } end def self.included(backend_class) backend_class.extend ClassMethods backend_class.option_reader :column_affix end module ClassMethods def valid_keys [:column_prefix, :column_suffix] end def configure(options) options[:column_affix] = "#{options[:column_prefix]}%s#{options[:column_suffix]}" end end private def column_name @column_name ||= (column_affix % attribute) end end private_constant :HashValued end end
Version data entries
31 entries across 31 versions & 1 rubygems