Sha256: 693dd192550720635c84bbaf1bfb6663a36d6899bae09e8ebe43ba00dcf740ca

Contents?: true

Size: 900 Bytes

Versions: 5

Compression:

Stored size: 900 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, **_)
        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

5 entries across 5 versions & 1 rubygems

Version Path
mobility-0.1.12 lib/mobility/backend/sequel/hstore.rb
mobility-0.1.11 lib/mobility/backend/sequel/hstore.rb
mobility-0.1.10 lib/mobility/backend/sequel/hstore.rb
mobility-0.1.7 lib/mobility/backend/sequel/hstore.rb
mobility-0.1.6 lib/mobility/backend/sequel/hstore.rb