Sha256: 342c10e55841f6238e878ea4932d1a80f67ea95293c1aa033a38fa697ac8b86e

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

module Mobility
  module Backend
=begin

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

@note This backend disables the +locale_accessors+ option, which would
  otherwise interfere with column methods.
=end
    class Sequel::Column
      include Backend
      include Mobility::Backend::Column

      autoload :QueryMethods, 'mobility/backend/sequel/column/query_methods'

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

      # @!group Backend Accessors
      # @!macro backend_writer
      # @!method write(locale, value, **options)

      # @!group Backend Configuration
      def self.configure!(options)
        options[:locale_accessors] = false
      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

1 entries across 1 versions & 1 rubygems

Version Path
mobility-0.1.6 lib/mobility/backend/sequel/column.rb