Sha256: 72473da3b0baf7f85c65ee2ae1f16d263d30b3e42718781fb7d183a81bafa985
Contents?: true
Size: 1.23 KB
Versions: 8
Compression:
Stored size: 1.23 KB
Contents
module Mobility module Backend =begin Internal class used by Sequel backends that store values as a hash. =end class Sequel::HashValued include Sequel # @!macro backend_reader def read(locale, **_) translations[locale.to_s] end # @!macro backend_writer def write(locale, value, **_) translations[locale.to_s] = value end # @!group Cache Methods def translations model.send("#{attribute}_before_mobility") end alias_method :new_cache, :translations # @return [Boolean] def write_to_cache? true end # @!endgroup setup do |attributes, options| method_overrides = Module.new do define_method :initialize_set do |values| attributes.each { |attribute| send(:"#{attribute}_before_mobility=", {}) } super(values) end define_method :before_validation do attributes.each do |attribute| send("#{attribute}_before_mobility").delete_if { |_, v| v.blank? } end super() end end include method_overrides include Mobility::Sequel::ColumnChanges.new(attributes) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems