Sha256: da05e9540a8019ec51ce7d9aea3c962dc657eeefbf8936ddaaebf8807e1ab3cc

Contents?: true

Size: 1002 Bytes

Versions: 13

Compression:

Stored size: 1002 Bytes

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
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mobility-0.8.13 lib/mobility/backends/sequel/hstore.rb
mobility-0.8.11 lib/mobility/backends/sequel/hstore.rb
mobility-0.8.10 lib/mobility/backends/sequel/hstore.rb
mobility-0.8.9 lib/mobility/backends/sequel/hstore.rb
mobility-0.8.8 lib/mobility/backends/sequel/hstore.rb
mobility-0.8.7 lib/mobility/backends/sequel/hstore.rb
mobility-0.8.6 lib/mobility/backends/sequel/hstore.rb
mobility-0.8.5 lib/mobility/backends/sequel/hstore.rb
mobility-0.8.4 lib/mobility/backends/sequel/hstore.rb
mobility-0.8.3 lib/mobility/backends/sequel/hstore.rb
mobility-0.8.2 lib/mobility/backends/sequel/hstore.rb
mobility-0.8.1 lib/mobility/backends/sequel/hstore.rb
mobility-0.8.0 lib/mobility/backends/sequel/hstore.rb