activerecord-mlang 0.0.4 → 0.0.5

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: 1a0d539db992bb9ce6ad288ab262f0ff0bbf2273
4
- data.tar.gz: 1d5a0b42b4757fc0f22c9ad96dbd37725fdacc2d
3
+ metadata.gz: cf207ea098da9f3fd92c5cfe188d582775c6dba0
4
+ data.tar.gz: 9c40da1d5ba8a67f2d1e76e6a2883baf8aebef7f
5
5
  SHA512:
6
- metadata.gz: d4f6b61612d6d075c7a8c63504828c1db8e8863dc66d158ab27a9e7d96cf1dfd5025b17c01282df0543f67e3481999c4bae698be510dde6048cc4b7e23038c51
7
- data.tar.gz: c2123709e96593b3b10f701c9d4a45a8399b99a4fdfdc7fb89d7e6cf2e65c4b0a3c5e0f8d8f061de6964ee739b96156ec3185b0d027e523699e8dc0e3e3b68c8
6
+ metadata.gz: c5ae9d993666bf7456999d8b601f301a3bae3e1634ff3a1b1ad7c390cdbf41be1175c335d5e682e8b4602043a56d487c84152745fe6bd0f0e971a351b177e3f0
7
+ data.tar.gz: bafb199672722d5688097c8bbf9ef811d4907f90d5db40d11095ca51cedd594fcb9d84001670f02b1ab48841c05a6fe0af4e917ac7f55d00aa3b298a5d48f0af
@@ -3,22 +3,9 @@ module ActiveRecord
3
3
  module Mlang
4
4
  class Lang < ActiveRecord::Base
5
5
  include ActiveRecord::Mlang
6
- # def self.drop_table!
7
- # connection.schema_cache.clear_table_cache!(table_name)
8
- # connection.drop_table table_name
9
- # end
10
-
11
- # def self.create_table!
12
- # connection.schema_cache.clear_table_cache!(table_name)
13
- # connection.create_table table_name do |t|
14
- # t.string :code, null: false, limit: 5
15
- # t.boolean :east, null: false, default: false
16
- # t.integer :position , default: 1 , null: false
17
- # t.boolean :enable, null: false, default: true
18
- # t.timestamps
19
- # end
20
- # connection.add_index table_name, [:code], unique: true
21
- # end
6
+ def self.[] code
7
+ find_by(code: code)
8
+ end
22
9
  end
23
10
  end
24
11
  end
@@ -53,7 +53,11 @@ module ActiveRecord
53
53
 
54
54
  def text(locale=nil)
55
55
  locale ||= I18n.default_locale
56
- texts.find_or_create_by(lang_id: Lang[locale].id)
56
+ if lang = Lang[locale]
57
+ texts.find_or_create_by(lang_id: lang.id)
58
+ else
59
+ nil
60
+ end
57
61
  end
58
62
  end
59
63
  end
@@ -1,5 +1,5 @@
1
1
  module Activerecord
2
2
  module Mlang
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-mlang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shinjiro Itagaki