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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc96cdbf093253128b133b2e05db04eb641c9b63
4
- data.tar.gz: e991fdbbc2b94853eabfa31dc252ebdd8b9a5cdf
3
+ metadata.gz: a19710b7c3a22a255dbe5ec007599dff63fb5f8d
4
+ data.tar.gz: 54e3895862efbe44127e9ff93d8ff9d7afd830e1
5
5
  SHA512:
6
- metadata.gz: 5f73a39be9d4e06ee3340d861a9d1fb4b48e2a2df73b4ec62c45abc314ba9c60674bd9b529133a3e07c2fedb2840fa9ad4b3b88d291f42c8082cf3c33549ab50
7
- data.tar.gz: 49fe1aadbacd582979fc8773d2e800b2cc4eab2ca8c01d6ab416affe7c742da440498f3a33a78e64fe50a6a24d45e8d99ace7265e3960fea87bd9a984ad622db
6
+ metadata.gz: 1f6f3adf6dd0c220667eb1fdc914b0022a7cfdba843d7599ffb37e11d9c33a9048f32f63be0e2df3348a25af2bb116d3191a1e39bf28cb7c2620dc737662d013
7
+ data.tar.gz: aa4bb0d026fb8a5ceb213b741895fb6d916b783c90b475c5a2bb9240c252c0ccf57ddbe6163a37a4173311b8c0fd7b66d04e8e91d7ba28f1e37538017972f5bc
@@ -51,13 +51,19 @@ module ActiveRecord
51
51
  end
52
52
  end
53
53
 
54
- def text(locale=nil)
55
- locale ||= I18n.default_locale
56
- if self.persisted? && lang = Lang[locale]
57
- texts.find_or_create_by(lang_id: lang.id)
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
- nil
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
@@ -1,5 +1,5 @@
1
1
  module Activerecord
2
2
  module Mlang
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  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.6
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-07 00:00:00.000000000 Z
11
+ date: 2015-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler