activerecord-mlang 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_record/mlang.rb +11 -5
- data/lib/activerecord/mlang/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a19710b7c3a22a255dbe5ec007599dff63fb5f8d
|
4
|
+
data.tar.gz: 54e3895862efbe44127e9ff93d8ff9d7afd830e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f6f3adf6dd0c220667eb1fdc914b0022a7cfdba843d7599ffb37e11d9c33a9048f32f63be0e2df3348a25af2bb116d3191a1e39bf28cb7c2620dc737662d013
|
7
|
+
data.tar.gz: aa4bb0d026fb8a5ceb213b741895fb6d916b783c90b475c5a2bb9240c252c0ccf57ddbe6163a37a4173311b8c0fd7b66d04e8e91d7ba28f1e37538017972f5bc
|
data/lib/active_record/mlang.rb
CHANGED
@@ -51,13 +51,19 @@ module ActiveRecord
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
def text(
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
def text(local_or_lang_id=nil)
|
55
|
+
return nil if !self.persisted?
|
56
|
+
local_or_lang_id ||= I18n.default_locale
|
57
|
+
lang_id = nil
|
58
|
+
if local_or_lang_id.kind_of? Integer
|
59
|
+
lang_id = local_or_lang_id if Lang.exists?(id: local_or_lang_id)
|
58
60
|
else
|
59
|
-
|
61
|
+
lang_id = Lang[local_or_lang_id].try(:id)
|
60
62
|
end
|
63
|
+
|
64
|
+
return nil if !lang_id
|
65
|
+
|
66
|
+
texts.find_or_create_by(lang_id: lang_id)
|
61
67
|
end
|
62
68
|
end
|
63
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-mlang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shinjiro Itagaki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|