simple_model_translations 0.2.2 → 0.2.3

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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_model_translations (0.2.1)
4
+ simple_model_translations (0.2.3)
5
5
  activerecord (~> 3.0.0)
6
6
 
7
7
  GEM
@@ -21,18 +21,8 @@ module SimpleModelTranslations
21
21
  configure_translations(attributes.extract_options!)
22
22
  translation_class.class_eval(&block) if block_given?
23
23
 
24
- attributes.each do |attribute|
25
- # attribute setter
26
- define_method "#{attribute}=" do |value|
27
- translation = find_or_build_translation_by_locale(I18n.locale)
28
- translation.send("#{attribute}=", value)
29
- end
30
-
31
- # attribute getter
32
- define_method attribute do
33
- current_translation ? current_translation.send(attribute) : nil
34
- end
35
- end
24
+ delegate *(attributes + [:to => :current_translation, :allow_nil => true])
25
+ delegate *(attributes.map { |attr| "#{attr}=" } + [:to => :find_or_build_current_translation])
36
26
  end
37
27
 
38
28
  private
@@ -24,6 +24,10 @@ module SimpleModelTranslations
24
24
  find_translation_by_locale(current_locale_for_translation) || find_translation_by_locale(default_locale_for_translation)
25
25
  end
26
26
 
27
+ def find_or_build_current_translation
28
+ find_or_build_translation_by_locale(current_locale_for_translation)
29
+ end
30
+
27
31
  private
28
32
  def foreign_object_key
29
33
  self.class.name.underscore.to_sym
@@ -1,3 +1,3 @@
1
1
  module SimpleModelTranslations
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_model_translations
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pavel Forkert