i18n_konjac 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb6bdef860009bbe752f11ef49d4707dded5fbcd
4
- data.tar.gz: 07d278acc291905d54268669f5f746368f123781
3
+ metadata.gz: bfe7f76271489ff7e81c5b43323bc14f13b63d0b
4
+ data.tar.gz: 853d0fe0b085ab9dc48253cbd6751a2482be0a62
5
5
  SHA512:
6
- metadata.gz: 2e0e6ad07d4bd7caebef4aa316085682bda952fa6d9cd9ca0733d5b4eb629b26036908bedccc4c408df6e768cee3f18e174f74c95aea024589ab0c1902963e89
7
- data.tar.gz: 3892d43d52310d8a39a5d4c3787a992b6cb0f34cc94819a01ed0e75f9b7f417db2c3f05a3a6727f521861faa9e08f6f807d778b4b69a624da9bd1e435fd835c1
6
+ metadata.gz: 3538d481c1e8a35e06bd26ced1374953f8dfb44ba61296c0f6c0e82553f40cb3f77e00e52b472e49705748c97eb4e91c3d13779bdd6fc2010e38715b95931ebb
7
+ data.tar.gz: cead67afe584748ce31c688c7aa211b26f31a1036da89aa504df348ca5a992786e873620ddb136f11ea4ed9dc77ee193129cf1d5faf7bfa28a9afb77e7f7b87d
@@ -6,21 +6,15 @@ module I18nKonjac
6
6
  def acts_as_konjac(options={})
7
7
  include I18nKonjac::ActsAsKonjac::LocalInstanceMethods
8
8
 
9
- self.column_names.each do |column|
10
- self.instance_eval do
11
- define_method "#{column}_by_locale" do
12
- if self.attribute_present?("#{current_prefix}#{column}")
13
- val = self.send("#{current_prefix}#{column}")
14
-
15
- # when value is empty.
16
- val = self.send("#{column}") if val.blank?
17
- else
18
- # when column is undefine
19
- val = self.send("#{column}") if val.blank?
20
- end
9
+ return unless ActiveRecord::Base.connection.table_exists? self.to_s.pluralize.underscore
21
10
 
22
- val
11
+ self.column_names.each do |column|
12
+ define_method "#{column}_by_locale" do
13
+ val = if self.attribute_present?("#{current_prefix}#{column}")
14
+ self.send("#{current_prefix}#{column}")
23
15
  end
16
+
17
+ val.presence || self.send("#{column}")
24
18
  end
25
19
  end
26
20
  end
@@ -1,3 +1,3 @@
1
1
  module I18nKonjac
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_konjac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - yaboojp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-17 00:00:00.000000000 Z
11
+ date: 2018-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -44,8 +44,7 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
- description: |2
48
- i18n_konjac
47
+ description: " i18n_konjac\n"
49
48
  email:
50
49
  - yaboo.ja@gmail.com
51
50
  executables: []
@@ -114,45 +113,45 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
113
  version: '0'
115
114
  requirements: []
116
115
  rubyforge_project:
117
- rubygems_version: 2.6.12
116
+ rubygems_version: 2.5.2
118
117
  signing_key:
119
118
  specification_version: 4
120
119
  summary: Add your ActiveRecord instance method, which is value translated by i18n
121
120
  locale
122
121
  test_files:
122
+ - test/dummy/app/controllers/application_controller.rb
123
+ - test/dummy/app/views/layouts/application.html.erb
123
124
  - test/dummy/app/assets/javascripts/application.js
124
125
  - test/dummy/app/assets/stylesheets/application.css
125
- - test/dummy/app/controllers/application_controller.rb
126
126
  - test/dummy/app/helpers/application_helper.rb
127
- - test/dummy/app/views/layouts/application.html.erb
128
- - test/dummy/bin/bundle
129
- - test/dummy/bin/rails
130
127
  - test/dummy/bin/rake
131
128
  - test/dummy/bin/setup
132
- - test/dummy/config/application.rb
133
- - test/dummy/config/boot.rb
134
- - test/dummy/config/database.yml
135
- - test/dummy/config/environment.rb
136
- - test/dummy/config/environments/development.rb
129
+ - test/dummy/bin/bundle
130
+ - test/dummy/bin/rails
131
+ - test/dummy/config/secrets.yml
132
+ - test/dummy/config/routes.rb
133
+ - test/dummy/config/locales/en.yml
137
134
  - test/dummy/config/environments/production.rb
135
+ - test/dummy/config/environments/development.rb
138
136
  - test/dummy/config/environments/test.rb
139
- - test/dummy/config/initializers/assets.rb
137
+ - test/dummy/config/environment.rb
138
+ - test/dummy/config/application.rb
139
+ - test/dummy/config/database.yml
140
+ - test/dummy/config/boot.rb
140
141
  - test/dummy/config/initializers/backtrace_silencers.rb
141
- - test/dummy/config/initializers/cookies_serializer.rb
142
- - test/dummy/config/initializers/filter_parameter_logging.rb
143
- - test/dummy/config/initializers/inflections.rb
144
142
  - test/dummy/config/initializers/mime_types.rb
143
+ - test/dummy/config/initializers/filter_parameter_logging.rb
145
144
  - test/dummy/config/initializers/session_store.rb
146
145
  - test/dummy/config/initializers/wrap_parameters.rb
147
- - test/dummy/config/locales/en.yml
148
- - test/dummy/config/routes.rb
149
- - test/dummy/config/secrets.yml
146
+ - test/dummy/config/initializers/assets.rb
147
+ - test/dummy/config/initializers/cookies_serializer.rb
148
+ - test/dummy/config/initializers/inflections.rb
150
149
  - test/dummy/config.ru
151
- - test/dummy/public/404.html
150
+ - test/dummy/Rakefile
151
+ - test/dummy/public/favicon.ico
152
152
  - test/dummy/public/422.html
153
153
  - test/dummy/public/500.html
154
- - test/dummy/public/favicon.ico
155
- - test/dummy/Rakefile
154
+ - test/dummy/public/404.html
156
155
  - test/dummy/README.rdoc
157
156
  - test/i18n_konjac_test.rb
158
157
  - test/test_helper.rb