hstore_translate 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hstore_translate/translates.rb +8 -2
- data/lib/hstore_translate/version.rb +1 -1
- data/test/translates_test.rb +5 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf335ea8fee1372bf9cc32b3ad3c046795dd6640
|
4
|
+
data.tar.gz: 6fae38f89cccbcf983a0844f0515e901d0fb6ea1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 514544c0ae6787c5ac08eb7240838ff050ff567a3f113f5f18202ebd7f7592b6bc94b62c1c3fad87f19a4438b2bad58fe569451f5e7bdf1c0e85314f0bc1b533
|
7
|
+
data.tar.gz: 09293243be9d6a2ba0e56dadc597f9e13c39275bea302e6438e31fd2dbae48080d59ef414b6b3eab7bfb3a07d47231861bc59cd45a4cbba4ae11ceefbde76af9
|
@@ -4,6 +4,7 @@ module HstoreTranslate
|
|
4
4
|
include InstanceMethods
|
5
5
|
|
6
6
|
class_attribute :translated_attrs
|
7
|
+
alias_attribute :translated_attribute_names, :translated_attrs # Improve compatibility with the gem globalize
|
7
8
|
self.translated_attrs = attrs
|
8
9
|
|
9
10
|
attrs.each do |attr_name|
|
@@ -12,11 +13,11 @@ module HstoreTranslate
|
|
12
13
|
define_method attr_name do
|
13
14
|
read_hstore_translation(attr_name)
|
14
15
|
end
|
15
|
-
|
16
|
+
|
16
17
|
define_method "#{attr_name}=" do |value|
|
17
18
|
write_hstore_translation(attr_name, value)
|
18
19
|
end
|
19
|
-
|
20
|
+
|
20
21
|
define_singleton_method "with_#{attr_name}_translation" do |value, locale = I18n.locale|
|
21
22
|
quoted_translation_store = connection.quote_column_name("#{attr_name}_translations")
|
22
23
|
where("#{quoted_translation_store} @> hstore(:locale, :value)", locale: locale, value: value)
|
@@ -27,6 +28,11 @@ module HstoreTranslate
|
|
27
28
|
alias_method_chain :method_missing, :translates
|
28
29
|
end
|
29
30
|
|
31
|
+
# Improve compatibility with the gem globalize
|
32
|
+
def translates?
|
33
|
+
included_modules.include?(InstanceMethods)
|
34
|
+
end
|
35
|
+
|
30
36
|
module InstanceMethods
|
31
37
|
def disable_fallback
|
32
38
|
@disable_fallback = true
|
data/test/translates_test.rb
CHANGED
@@ -112,11 +112,15 @@ class TranslatesTest < HstoreTranslate::Test
|
|
112
112
|
p.reload
|
113
113
|
assert_equal({"en" => "English Title", "fr" => "Titre français"}, p.title_translations)
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
def test_with_translation_relation
|
117
117
|
p = Post.create!(:title_translations => { "en" => "Alice in Wonderland", "fr" => "Alice au pays des merveilles" })
|
118
118
|
I18n.with_locale(:en) do
|
119
119
|
assert_equal p.title_en, Post.with_title_translation("Alice in Wonderland").first.try(:title)
|
120
120
|
end
|
121
121
|
end
|
122
|
+
|
123
|
+
def test_class_method_translates?
|
124
|
+
assert_equal true, Post.translates?
|
125
|
+
end
|
122
126
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hstore_translate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Worley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.1.11
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: Rails I18n library for ActiveRecord model/data translation using PostgreSQL's
|