activerecord-mlang 0.0.8 → 0.0.9

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: 65f9c56074f0f729bbf21d7792fb41cb2185c6a5
4
- data.tar.gz: c0e5bf520d0a6deaf49c9a5fe7ccc7d62ecb252e
3
+ metadata.gz: b6d876dfc4e28efbff05f9aca3a14d3cbc650bbd
4
+ data.tar.gz: cb092b2200010930203be266e1f07fdf0db32b0c
5
5
  SHA512:
6
- metadata.gz: c7a9b0374bbdeface0a84c3abd75ea74898faeca6aad3bee4628d12cac890c9eaec31a21925874510870b0fc8e256158d753debef302dccb718d54a7bc2c4912
7
- data.tar.gz: ef1a59ce54638d120638d1adc86da2f02f1a1e3c88a5b21838cae9d1de1ad5bd2b71f7050fe27a32644ca64ef7b2ead39576d17cf2bb85c828459dcc4a1c34e0
6
+ metadata.gz: bd7ecb212e4db96e99f1f96ef4fb479a848d53a72bd3dcf2f52f6250945472e4ab05a080db6597e24dce8faa28679297b32d13770bdf5af9ca124f593f55492a
7
+ data.tar.gz: fdebe50f6d39be6e9f49610dc5420d28676e437969444f7b336a2dd89244b246d444c56741b3231f915178d1df617a13a447bd7cd4514687c95a9647702a2297
@@ -51,19 +51,13 @@ module ActiveRecord
51
51
  end
52
52
  end
53
53
 
54
- def text(local_or_lang_id=nil)
54
+ def text(locale_or_lang_id=nil)
55
55
  return nil if !self.persisted?
56
- local_or_lang_id ||= I18n.locale || 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)
60
- else
61
- lang_id = Lang[local_or_lang_id].try(:id)
62
- end
63
56
 
64
- return nil if !lang_id
57
+ locale_or_lang_id ||= I18n.locale || I18n.default_locale
58
+ return nil if !(lang = Lang[locale_or_lang_id])
65
59
 
66
- texts.find_or_create_by(lang_id: lang_id)
60
+ texts.find_or_create_by(lang_id: lang.id)
67
61
  end
68
62
  end
69
63
  end
@@ -3,8 +3,12 @@ module ActiveRecord
3
3
  module Mlang
4
4
  class Lang < ActiveRecord::Base
5
5
  include ActiveRecord::Mlang
6
- def self.[] code
7
- find_by(code: code)
6
+ def self.[] locale_or_lang_id
7
+ if locale_or_lang_id.kind_of? Integer
8
+ self.find_by(id: locale_or_lang_id)
9
+ else
10
+ self.find_by(code: locale_or_lang_id)
11
+ end
8
12
  end
9
13
  end
10
14
  end
@@ -1,5 +1,5 @@
1
1
  module Activerecord
2
2
  module Mlang
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
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.8
4
+ version: 0.0.9
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-10-08 00:00:00.000000000 Z
11
+ date: 2015-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler