Sha256: 815c49105c7051448315b270cb9c07dc3dfbfae7334eac5f61cd133872f2968b
Contents?: true
Size: 1013 Bytes
Versions: 1
Compression:
Stored size: 1013 Bytes
Contents
# frozen-string-literal: true module Mobility module Plugins module Writer =begin Defines attribute writer that delegates to +Mobility::Backend#write+. =end extend Plugin default true requires :backend initialize_hook do |*names| if options[:writer] names.each do |name| class_eval <<-EOM, __FILE__, __LINE__ + 1 def #{name}=(value, locale: nil, **options) #{Writer.setup_source} mobility_backends[:#{name}].write(locale, value, options) end EOM end end end def self.setup_source <<-EOL return super(value) if options[:super] if (locale &&= locale.to_sym) #{"Mobility.enforce_available_locales!(locale)" if I18n.enforce_available_locales} options[:locale] = true else locale = Mobility.locale end EOL end end register_plugin(:writer, Writer) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mobility-1.0.0.alpha | lib/mobility/plugins/writer.rb |