Sha256: aedd4240f9293538f2e77397541cee38e08e8e6291c214e54f4ee1698f164bd3
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true require "mobility/util" require "mobility/backends/sequel" require "mobility/backends/hash_valued" require "mobility/backend/stringify_locale" require "mobility/sequel/column_changes" module Mobility module Backends =begin Internal class used by Sequel backends backed by a Postgres data type (hstore, jsonb). =end class Sequel::PgHash include Sequel include HashValued include StringifyLocale # @!macro backend_iterator def each_locale super { |l| yield l.to_sym } end def translations model[attribute.to_sym] end setup do |attributes| before_validation = Module.new do define_method :before_validation do attributes.each do |attribute| self[attribute.to_sym].delete_if { |_, v| Util.blank?(v) } end super() end end include before_validation include Mobility::Sequel::HashInitializer.new(*attributes) include Mobility::Sequel::ColumnChanges.new(*attributes) plugin :defaults_setter attributes.each { |attribute| default_values[attribute.to_sym] = {} } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mobility-0.5.1 | lib/mobility/backends/sequel/pg_hash.rb |
mobility-0.5.0 | lib/mobility/backends/sequel/pg_hash.rb |