mobility 0.3.6 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +21 -0
- data/Gemfile +11 -9
- data/Gemfile.lock +9 -6
- data/README.md +50 -16
- data/lib/mobility.rb +18 -4
- data/lib/mobility/active_record.rb +14 -7
- data/lib/mobility/active_record/uniqueness_validator.rb +17 -3
- data/lib/mobility/attributes.rb +39 -16
- data/lib/mobility/backends/active_record/column/query_methods.rb +12 -11
- data/lib/mobility/backends/active_record/container.rb +116 -0
- data/lib/mobility/backends/active_record/container/query_methods.rb +31 -0
- data/lib/mobility/backends/active_record/hstore/query_methods.rb +7 -54
- data/lib/mobility/backends/active_record/jsonb/query_methods.rb +5 -55
- data/lib/mobility/backends/active_record/key_value.rb +13 -9
- data/lib/mobility/backends/active_record/key_value/query_methods.rb +6 -6
- data/lib/mobility/backends/active_record/pg_query_methods.rb +115 -0
- data/lib/mobility/backends/active_record/query_methods.rb +4 -3
- data/lib/mobility/backends/active_record/serialized/query_methods.rb +6 -5
- data/lib/mobility/backends/active_record/table.rb +18 -3
- data/lib/mobility/backends/active_record/table/query_methods.rb +25 -14
- data/lib/mobility/backends/container.rb +25 -0
- data/lib/mobility/backends/hash_valued.rb +2 -2
- data/lib/mobility/backends/null.rb +2 -2
- data/lib/mobility/backends/sequel/column.rb +2 -2
- data/lib/mobility/backends/sequel/column/query_methods.rb +2 -2
- data/lib/mobility/backends/sequel/container.rb +99 -0
- data/lib/mobility/backends/sequel/container/query_methods.rb +41 -0
- data/lib/mobility/backends/sequel/hstore/query_methods.rb +17 -3
- data/lib/mobility/backends/sequel/jsonb/query_methods.rb +17 -3
- data/lib/mobility/backends/sequel/key_value.rb +2 -1
- data/lib/mobility/backends/sequel/key_value/query_methods.rb +2 -2
- data/lib/mobility/backends/sequel/pg_hash.rb +4 -7
- data/lib/mobility/backends/sequel/pg_query_methods.rb +85 -0
- data/lib/mobility/backends/sequel/query_methods.rb +4 -3
- data/lib/mobility/backends/sequel/serialized/query_methods.rb +4 -3
- data/lib/mobility/backends/sequel/table.rb +1 -1
- data/lib/mobility/backends/sequel/table/query_methods.rb +2 -2
- data/lib/mobility/backends/serialized.rb +5 -7
- data/lib/mobility/configuration.rb +34 -4
- data/lib/mobility/plugins/active_record/dirty.rb +1 -1
- data/lib/mobility/plugins/fallbacks.rb +20 -6
- data/lib/mobility/sequel/column_changes.rb +2 -5
- data/lib/mobility/sequel/hash_initializer.rb +19 -0
- data/lib/mobility/util.rb +0 -2
- data/lib/mobility/version.rb +1 -1
- metadata +11 -4
- metadata.gz.sig +0 -0
- data/lib/mobility/backends/sequel/postgres_query_methods.rb +0 -41
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module Mobility
|
2
|
-
module Backends
|
3
|
-
module PostgresQueryMethods
|
4
|
-
private
|
5
|
-
|
6
|
-
def define_query_methods(column_type)
|
7
|
-
attributes_extractor = @attributes_extractor
|
8
|
-
|
9
|
-
%w[exclude or where].each do |method_name|
|
10
|
-
invert = method_name == "exclude"
|
11
|
-
|
12
|
-
define_method method_name do |*cond, &block|
|
13
|
-
if i18n_keys = attributes_extractor.call(cond.first)
|
14
|
-
locale = Mobility.locale.to_s
|
15
|
-
cond = cond.first
|
16
|
-
|
17
|
-
i18n_query = i18n_keys.inject(::Sequel.expr(!invert)) do |expr, attr|
|
18
|
-
value = cond.delete(attr)
|
19
|
-
op = ::Sequel.send(:"#{column_type}_op", attr)
|
20
|
-
contains_value = op.contains({ locale => value.to_s })
|
21
|
-
has_key = op.has_key?(locale)
|
22
|
-
if invert
|
23
|
-
expr.|(has_key & ~contains_value)
|
24
|
-
else
|
25
|
-
expr.&(value.nil? ? ~has_key : contains_value)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
if method_name == "or"
|
29
|
-
cond.empty? ? super(i18n_query, &block) : super(::Sequel.&(cond, i18n_query), &block)
|
30
|
-
else
|
31
|
-
super(cond, &block).where(i18n_query)
|
32
|
-
end
|
33
|
-
else
|
34
|
-
super(*cond, &block)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|