has_localization_table 0.3.4 → 0.3.5
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
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MWMxOGEwOTdjY2U5OWM3YTAwZDNhN2RhMWQ1N2IyODQ3YWZkYjU5YQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YzUzNzFiMzk3MDViYzZmOWE4NWM3NzQ2ZjIzOWE4NTkxYzkwMjcyNA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MmUzNzEyOTAxMGYyNGY5MmM4MWEwNjFiZTY4M2FiY2Q0Y2Y4Njc1ZjZiZjRh
|
10
|
+
ZDQwMGE1ODM4ZmFhNGVlYjc3NWYyNWQ2NmQ0MzY0MWI5NjU5NGU5ODBmODZl
|
11
|
+
ZWE1NGVkNzIxMWQ2ZDgxZTUyZmUxNWMxNDc5ZGJiZmY4YTY0Zjg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
M2Y4YzlhZTBjZThmZTM4ZDQwNTQyYTYxMGRlZjgwNmYyZWJjYTkxNDViNWMz
|
14
|
+
YTg1ZTk5YzEwMjY3MDkzNWFmZTNlYzc3ZjFiNzI4ZjliYTliMjc4YTE0MTMy
|
15
|
+
ZDI4YzJiODE2NjM4NTQ3ODkwNDkwNThmNTYzZGY4YWJlODIxMGU=
|
@@ -9,12 +9,12 @@ module HasLocalizationTable
|
|
9
9
|
alias_method :"with_#{klass.localization_association_name}", :with_localizations
|
10
10
|
end
|
11
11
|
|
12
|
-
def with_localizations
|
12
|
+
def with_localizations(locale = HasLocalizationTable.current_locale.id)
|
13
13
|
lcat = localization_class.arel_table
|
14
14
|
|
15
15
|
scoped.joins(
|
16
16
|
arel_table.join(lcat, Arel::Nodes::OuterJoin).
|
17
|
-
on(lcat[:"#{self.name.underscore}_id"].eq(arel_table[self.primary_key]).and(lcat[HasLocalizationTable.locale_foreign_key].eq(
|
17
|
+
on(lcat[:"#{self.name.underscore}_id"].eq(arel_table[self.primary_key]).and(lcat[HasLocalizationTable.locale_foreign_key].eq(locale))).
|
18
18
|
join_sql
|
19
19
|
)
|
20
20
|
end
|
@@ -46,7 +46,12 @@ module HasLocalizationTable
|
|
46
46
|
|
47
47
|
# Collect all localizations for the object
|
48
48
|
def create_has_many_association
|
49
|
-
self.has_many localization_association_name, localization_table_options.except(:association_name, :required, :optional, :has_one)
|
49
|
+
self.has_many localization_association_name, localization_table_options.except(:association_name, :required, :optional, :has_one) do
|
50
|
+
def for_locale(locale)
|
51
|
+
# where(HasLocalizationTable.locale_foreign_key => locale).first
|
52
|
+
select{ |s| s.send(HasLocalizationTable.locale_foreign_key) == locale }.first
|
53
|
+
end
|
54
|
+
end
|
50
55
|
end
|
51
56
|
|
52
57
|
public
|
metadata
CHANGED
@@ -1,80 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_localization_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Daniel Vandersluis
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-06-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
14
|
+
type: :runtime
|
16
15
|
prerelease: false
|
16
|
+
name: activesupport
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 3.0.0
|
22
|
-
none: false
|
23
|
-
type: :runtime
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
23
|
requirements:
|
26
24
|
- - ! '>='
|
27
25
|
- !ruby/object:Gem::Version
|
28
26
|
version: 3.0.0
|
29
|
-
none: false
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
|
28
|
+
type: :runtime
|
32
29
|
prerelease: false
|
30
|
+
name: activerecord
|
33
31
|
requirement: !ruby/object:Gem::Requirement
|
34
32
|
requirements:
|
35
33
|
- - ! '>='
|
36
34
|
- !ruby/object:Gem::Version
|
37
35
|
version: 3.0.0
|
38
|
-
none: false
|
39
|
-
type: :runtime
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
37
|
requirements:
|
42
38
|
- - ! '>='
|
43
39
|
- !ruby/object:Gem::Version
|
44
40
|
version: 3.0.0
|
45
|
-
none: false
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
|
-
|
42
|
+
type: :development
|
48
43
|
prerelease: false
|
44
|
+
name: minitest
|
49
45
|
requirement: !ruby/object:Gem::Requirement
|
50
46
|
requirements:
|
51
47
|
- - ! '>='
|
52
48
|
- !ruby/object:Gem::Version
|
53
49
|
version: '0'
|
54
|
-
none: false
|
55
|
-
type: :development
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
52
|
- - ! '>='
|
59
53
|
- !ruby/object:Gem::Version
|
60
54
|
version: '0'
|
61
|
-
none: false
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
|
-
|
56
|
+
type: :development
|
64
57
|
prerelease: false
|
58
|
+
name: sqlite3
|
65
59
|
requirement: !ruby/object:Gem::Requirement
|
66
60
|
requirements:
|
67
61
|
- - ! '>='
|
68
62
|
- !ruby/object:Gem::Version
|
69
63
|
version: '0'
|
70
|
-
none: false
|
71
|
-
type: :development
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
65
|
requirements:
|
74
66
|
- - ! '>='
|
75
67
|
- !ruby/object:Gem::Version
|
76
68
|
version: '0'
|
77
|
-
none: false
|
78
69
|
description: Automatically sets up usage of a relational table to contain user-created
|
79
70
|
multi-locale string attributes
|
80
71
|
email:
|
@@ -110,6 +101,7 @@ files:
|
|
110
101
|
- spec/support/setup.rb
|
111
102
|
homepage: https://github.com/dvandersluis/has_localization_table
|
112
103
|
licenses: []
|
104
|
+
metadata: {}
|
113
105
|
post_install_message:
|
114
106
|
rdoc_options: []
|
115
107
|
require_paths:
|
@@ -119,18 +111,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
111
|
- - ! '>='
|
120
112
|
- !ruby/object:Gem::Version
|
121
113
|
version: '0'
|
122
|
-
none: false
|
123
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
115
|
requirements:
|
125
116
|
- - ! '>='
|
126
117
|
- !ruby/object:Gem::Version
|
127
118
|
version: '0'
|
128
|
-
none: false
|
129
119
|
requirements: []
|
130
120
|
rubyforge_project:
|
131
|
-
rubygems_version: 1.
|
121
|
+
rubygems_version: 2.1.5
|
132
122
|
signing_key:
|
133
|
-
specification_version:
|
123
|
+
specification_version: 4
|
134
124
|
summary: Sets up associations and attribute methods for AR models that have a relational
|
135
125
|
table to contain user-created data in multiple languages.
|
136
126
|
test_files:
|