Sha256: f8b272d4b000513dccdecd4d795e704dca1c86379e1781ff38587442daabcc93
Contents?: true
Size: 1.23 KB
Versions: 2
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 Backend # @!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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mobility-0.1.5 | lib/mobility/backend/sequel/hash_valued.rb |
mobility-0.1.4 | lib/mobility/backend/sequel/hash_valued.rb |