/
jsonb.rb
36 lines (29 loc) · 1.11 KB
/
jsonb.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require 'mobility/backends/active_record/pg_hash'
module Mobility
module Backends
=begin
Implements the {Mobility::Backends::Jsonb} backend for ActiveRecord models.
@see Mobility::Backends::ActiveRecord::HashValued
=end
class ActiveRecord::Jsonb < ActiveRecord::PgHash
require 'mobility/backends/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_query_methods(QueryMethods)
end
end
end