Sha256: e75e20c536a7ca6049cdee9e33f3bd90f504cb3e9944da10cc9c59dfeeddedf0

Contents?: true

Size: 1.03 KB

Versions: 30

Compression:

Stored size: 1.03 KB

Contents

require 'mobility/backends/sequel/pg_hash'

Sequel.extension :pg_hstore, :pg_hstore_ops

module Mobility
  module Backends
=begin

Implements the {Mobility::Backends::Hstore} backend for Sequel models.

@see Mobility::Backends::HashValued

=end
    module Sequel
      class Hstore < PgHash
        # @!group Backend Accessors
        # @!macro backend_reader
        # @!method read(locale, options = {})

        # @!group Backend Accessors
        # @!macro backend_writer
        def write(locale, value, options = {})
          super(locale, value && value.to_s, **options)
        end
        # @!endgroup

        # @param [Symbol] name Attribute name
        # @param [Symbol] locale Locale
        # @return [Mobility::Backends::Sequel::Hstore::HStoreOp]
        def self.build_op(attr, locale)
          column_name = column_affix % attr
          HStoreOp.new(column_name.to_sym)[locale.to_s]
        end

        class HStoreOp < ::Sequel::Postgres::HStoreOp; end
      end
    end

    register_backend(:sequel_hstore, Sequel::Hstore)
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
mobility-1.3.1 lib/mobility/backends/sequel/hstore.rb
mobility-1.3.0 lib/mobility/backends/sequel/hstore.rb
mobility-1.3.0.rc3 lib/mobility/backends/sequel/hstore.rb
mobility-1.3.0.rc2 lib/mobility/backends/sequel/hstore.rb
mobility-1.3.0.rc1 lib/mobility/backends/sequel/hstore.rb
mobility-1.2.9 lib/mobility/backends/sequel/hstore.rb
mobility-1.2.8 lib/mobility/backends/sequel/hstore.rb
mobility-1.2.7 lib/mobility/backends/sequel/hstore.rb
mobility-1.2.6 lib/mobility/backends/sequel/hstore.rb
mobility-1.2.5 lib/mobility/backends/sequel/hstore.rb
mobility-1.2.4 lib/mobility/backends/sequel/hstore.rb
mobility-1.2.3 lib/mobility/backends/sequel/hstore.rb
mobility-1.2.2 lib/mobility/backends/sequel/hstore.rb
mobility-1.2.1 lib/mobility/backends/sequel/hstore.rb
mobility-1.2.0 lib/mobility/backends/sequel/hstore.rb
mobility-1.1.3 lib/mobility/backends/sequel/hstore.rb
mobility-1.1.2 lib/mobility/backends/sequel/hstore.rb
mobility-1.1.1 lib/mobility/backends/sequel/hstore.rb
mobility-1.1.0 lib/mobility/backends/sequel/hstore.rb
mobility-1.0.7 lib/mobility/backends/sequel/hstore.rb