Sha256: 0331a739ed6a783db2a0fd4e7e420e544da112b625dff41e7cb8f524fd1299fc

Contents?: true

Size: 906 Bytes

Versions: 4

Compression:

Stored size: 906 Bytes

Contents

require 'mobility/backend/sequel/hash_valued'

module Mobility
  module Backend
=begin

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

@see Mobility::Backend::Sequel::HashValued

=end
    class Sequel::Hstore < Sequel::HashValued
      autoload :QueryMethods, 'mobility/backend/sequel/hstore/query_methods'

      # @!group Backend Accessors
      # @!macro backend_reader
      # @!method read(locale, **options)

      # @!group Backend Accessors
      # @!macro backend_writer
      def write(locale, value, **options)
        translations[locale.to_s] = value && value.to_s
      end
      # @!endgroup

      setup do |attributes, options|
        extension = Module.new do
          define_method :i18n do
            @mobility_scope ||= super().with_extend(QueryMethods.new(attributes, options))
          end
        end
        extend extension
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mobility-0.1.3 lib/mobility/backend/sequel/hstore.rb
mobility-0.1.2 lib/mobility/backend/sequel/hstore.rb
mobility-0.1.1 lib/mobility/backend/sequel/hstore.rb
mobility-0.1.0 lib/mobility/backend/sequel/hstore.rb