Sha256: 04e59ec8b70fbfa7caa4ddb67fd4ead6b298159d8286d1bcf11088410345db1a

Contents?: true

Size: 1.34 KB

Versions: 11

Compression:

Stored size: 1.34 KB

Contents

require 'mobility/backend/active_record/hash_valued'

module Mobility
  module Backend
=begin

Implements the {Mobility::Backend::Jsonb} backend for ActiveRecord models.

@see Mobility::Backend::ActiveRecord::HashValued

=end
    class ActiveRecord::Jsonb < ActiveRecord::HashValued
      autoload :QueryMethods, 'mobility/backend/active_record/jsonb/query_methods'

      # @!group Backend Accessors
      #
      # @note Translation may be string, integer or boolean-valued since
      #   value is stored on a JSON hash.
      # @param [Symbol] locale Locale to read
      # @param [Hash] options
      # @return [String,Integer,Boolean] Value of translation
      # @!method read(locale, **options)

      # @!group Backend Accessors
      # @note Translation may be string, integer or boolean-valued since
      #   value is stored on a JSON hash.
      # @param [Symbol] locale Locale to write
      # @param [String,Integer,Boolean] value Value to write
      # @param [Hash] options
      # @return [String,Integer,Boolean] Updated value
      # @!method write(locale, value, **options)

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mobility-0.1.12 lib/mobility/backend/active_record/jsonb.rb
mobility-0.1.11 lib/mobility/backend/active_record/jsonb.rb
mobility-0.1.10 lib/mobility/backend/active_record/jsonb.rb
mobility-0.1.7 lib/mobility/backend/active_record/jsonb.rb
mobility-0.1.6 lib/mobility/backend/active_record/jsonb.rb
mobility-0.1.5 lib/mobility/backend/active_record/jsonb.rb
mobility-0.1.4 lib/mobility/backend/active_record/jsonb.rb
mobility-0.1.3 lib/mobility/backend/active_record/jsonb.rb
mobility-0.1.2 lib/mobility/backend/active_record/jsonb.rb
mobility-0.1.1 lib/mobility/backend/active_record/jsonb.rb
mobility-0.1.0 lib/mobility/backend/active_record/jsonb.rb