smooth_operator 1.10.17 → 1.10.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmU3ZWY3OGVjOTg5NTNmMGNiMTI4N2U5YTAyYjQzOGI1MGQ4NjNhMQ==
4
+ YmQ3ZWNiNWFhZGZiNWYyOGJiZmQ5Y2VlNjEyNTc4MzRlYzNiMzE2MA==
5
5
  data.tar.gz: !binary |-
6
- NWY2YWE5NmVmZjM4YzBlNTRhZGJmMjVlODM3M2QxY2ViZDRmMmNmMg==
6
+ MWVlNzhiNWZhNjFlYWJlY2Q3YzY3MDM2NTZmYmJkZGMwMGM3YzIyZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTAxMGQ5YWU1MTFkNzE5OTliZTY0YjU4ZWZiNTVhM2E0Zjg3ODVjZDIzM2Fh
10
- NzhmN2FlZmEzM2I4NGJjYTM0ZTUzZGYwZmQ3YWJkODdiNDRkMjJiY2YyNjgz
11
- MzNmNmM4OWJlOThlYjM4ZjlmYzVkODIzNDNkNWIzMDcxOTFhNzM=
9
+ OThjMTlhZTA3MmY1ZDNjZjZmZTRiNmZiMDZlZDgxOTVhMGM0YzFlNTBiZTMw
10
+ MzBmNzZhOWI4NDgyYTBlZWFkNzUxNDUyNjA4MjQ4NjE2MzU0OTkwN2ViN2Uy
11
+ MDIwMDM4YzRiNmJiOTEyMjgxMDE5MTRjODJkMmRjN2I3NWMxYmM=
12
12
  data.tar.gz: !binary |-
13
- MDZiOTJjNmQ1ZTVjNzZmZTc0MWI3MTU5NjBmYTU0ZTY3ZTBhNmUxY2NkZDg2
14
- OTk5MzVhNDhmYTBhNTlhYWE0NmFiNmM1MTAyMGM0ZDMxM2VmZTUzZmU2YjE0
15
- ZWI0MzBiMDI5MDVkZWRlYjUzNmMwMTMyNDk0OWQxMzk4MzM0MTA=
13
+ NmFiNjRhYzkxNWQ4ZTFkOTM0OGEyMTUzZjE3ZjE2ZjNmMTdjNzE5OGRjYjBi
14
+ MDM5NGZmYTIxMGUyOGFkMGIyYWRhZTcyNzY0MWNmZDhjZWU4NjY5ZTUzMTlh
15
+ OGNiNTRjZDQyZGZmZWI3YWQxZTgzZTZlY2M2MDM5YWY2MjgxZGI=
@@ -71,7 +71,10 @@ module SmoothOperator
71
71
  namespace ||= self.parents.detect do |n|
72
72
  n.respond_to?(:use_relative_model_naming?) && n.use_relative_model_naming?
73
73
  end
74
- ActiveModel::Name.new(self, namespace, @_model_name)
74
+
75
+ ActiveModel::Name.new(self, namespace, @_model_name).tap do |model_name|
76
+ def model_name.human(options = {}); @klass.send(:_translate, "models.#{i18n_key}", options); end
77
+ end
75
78
  end
76
79
  end
77
80
 
@@ -3,16 +3,23 @@ module SmoothOperator
3
3
  module Translation
4
4
 
5
5
  def human_attribute_name(attribute_key_name, options = {})
6
+ _translate("attributes.#{model_name.i18n_key}.#{attribute_key_name}", options = {})
7
+ end
8
+
9
+
10
+ private ###################### PRIVATE #########################
11
+
12
+ def _translate(namespace = '', options = {})
6
13
  no_translation = "-- no translation --"
7
14
 
8
- defaults = ["smooth_operator.attributes.#{model_name.i18n_key}.#{attribute_key_name}".to_sym]
9
- defaults << "activerecord.attributes.#{model_name.i18n_key}.#{attribute_key_name}".to_sym
15
+ defaults = ["smooth_operator.#{namespace}".to_sym]
16
+ defaults << "activerecord.#{namespace}".to_sym
10
17
  defaults << options[:default] if options[:default]
11
18
  defaults.flatten!
12
19
  defaults << no_translation
13
- options[:count] ||= 1
14
20
 
15
- I18n.translate(defaults.shift, options.merge(default: defaults))
21
+ options = { count: 1, default: defaults }.merge!(options.except(:default))
22
+ I18n.translate(defaults.shift, options)
16
23
  end
17
24
 
18
25
  end
@@ -1,3 +1,3 @@
1
1
  module SmoothOperator
2
- VERSION = "1.10.17"
2
+ VERSION = "1.10.18"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smooth_operator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.17
4
+ version: 1.10.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Gonçalves