from_clause_translate 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61a7a0b83c04d5cc4e15a088c9a56ad2388700bc1a6de3c477860501fdcfd16e
|
4
|
+
data.tar.gz: 1fd848f0dda4626997dc32742616117b4fcc3017219a30133d3c585ec0408a2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85e5ab0a94cd12927ed91ac819d4c4775374dbb217cf23d4511d9c4f292ba11ff5470c1d444b01fff500c51c737dc52904ff0a60f3dac75cdb695dfab8779c45
|
7
|
+
data.tar.gz: 4e032681587d35263fbae5bdf3f70b06f51f10104c3495ffa311d0fef8ec195759825d2b36a239c4a04a609fa19966376a9a14fbfe9f7fe4d0b479a642bb7b3a
|
@@ -24,14 +24,10 @@ module ClassMethods
|
|
24
24
|
column = plural.to_s.singularize.to_sym
|
25
25
|
selection = I18n.available_locales.map do |locale|
|
26
26
|
"#{quoted_table_name}.\"#{column}_#{locale}\""
|
27
|
-
end
|
28
|
-
I18n.available_locales.each do |locale|
|
29
|
-
self::TRANSLATED_SELECTION[locale][plural] = selection
|
30
|
-
end
|
31
|
-
selection = selection.join ','
|
27
|
+
end.join ','
|
32
28
|
self::TRANSLATED_PLURALS[plural] = selection
|
33
29
|
I18n.available_locales.each do |locale|
|
34
|
-
self::
|
30
|
+
self::TRANSLATED_SELECTION[locale][plural] = selection
|
35
31
|
end
|
36
32
|
end
|
37
33
|
end
|
@@ -69,8 +65,7 @@ module ClassMethods
|
|
69
65
|
selection = "#{quoted_table_name}.\"#{column}_#{locale}\""
|
70
66
|
selection = translated_fallbacks_wrap selection, fallback[locale]
|
71
67
|
selection = translated_fallbacks_wrap selection, fallback[:_]
|
72
|
-
self::TRANSLATED_SELECTION[locale][column] = selection
|
73
|
-
self::TRANSLATED_SELECTION_AS[locale][column] = "#{selection} AS #{column}"
|
68
|
+
self::TRANSLATED_SELECTION[locale][column] = "#{selection} AS #{column}"
|
74
69
|
end
|
75
70
|
end
|
76
71
|
|
@@ -27,7 +27,7 @@ class FromClauseTranslate::TranslatedColumnsBuilder
|
|
27
27
|
|
28
28
|
@has_translated = true
|
29
29
|
translated.each do |column|
|
30
|
-
next translated_selection(column)
|
30
|
+
next translated_selection(column) unless column.is_a? Hash
|
31
31
|
|
32
32
|
column.each do |key, value|
|
33
33
|
@skip_translated << key.to_s
|
@@ -40,24 +40,17 @@ class FromClauseTranslate::TranslatedColumnsBuilder
|
|
40
40
|
return if @without_projections
|
41
41
|
|
42
42
|
@arel.projections.each do |column|
|
43
|
+
next if column.is_a?(String) && column[0] != '"'
|
44
|
+
|
43
45
|
arel_projection_translation column
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
47
49
|
def arel_projection_translation column
|
48
|
-
return if column.is_a?(String) && column[0] != '"'
|
49
|
-
|
50
50
|
column = column.name if column.is_a? Arel::Attributes::Attribute
|
51
51
|
column = column.to_s unless column.is_a? String
|
52
52
|
|
53
|
-
|
54
|
-
name = column[1...-1]
|
55
|
-
elsif column == '*'
|
56
|
-
@select_all = true
|
57
|
-
return column
|
58
|
-
else
|
59
|
-
name = column
|
60
|
-
end
|
53
|
+
name = column.first == '"' ? column[1...-1] : column
|
61
54
|
|
62
55
|
return if @skip_translated.include? name
|
63
56
|
|
@@ -116,11 +109,13 @@ class FromClauseTranslate::TranslatedColumnsBuilder
|
|
116
109
|
sym = name.to_sym
|
117
110
|
translates = @klass.translates? sym
|
118
111
|
@has_translated = true
|
119
|
-
|
120
|
-
|
121
|
-
@columns << select
|
122
|
-
elsif !@select_all && @klass.columns_hash[name.to_s]
|
123
|
-
@columns << (original || name)
|
112
|
+
if translates
|
113
|
+
return @columns << @klass::TRANSLATED_SELECTION[I18n.locale][sym]
|
124
114
|
end
|
115
|
+
|
116
|
+
@select_all = true if sym == :*
|
117
|
+
return if @select_all || !@klass.columns_hash[name.to_s]
|
118
|
+
|
119
|
+
@columns << (original || name)
|
125
120
|
end
|
126
121
|
end
|