object_attorney 0.0.14 → 0.0.15

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTExZGJiODQ3MjYzZmFhOWY3YjAxMDk1OTc1ZWMyYzhkOTJhMWUzZA==
4
+ YzYwNjRlODU3YjdhMGJhMDRmZjA3M2NmODRhZDBlZjAyYjIyMTIwNA==
5
5
  data.tar.gz: !binary |-
6
- ZGM3YTFmN2FmMjE1NDg5MWM1N2VjZGQ5NzU5NzE1OTQ4MjZlNzI2YQ==
6
+ ZDg3YTQ2ZjYyM2JmNjIwNzI2OTA5YTFhNjZkM2Y4MWUwYmQzOWI0YQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NmYwOTExOTEyMDQ1YmJjNjBjMDA0NTYxYjY0ZDVlNTBiNzU3MzgxNTU1NzMw
10
- MjMwYmZmNjNlNDVhNTllODgwYzAzYTI2ZGI4MmUyOGQ4ZTQ3N2IxYjgwYWVl
11
- MmEzNGMwNzZhODY2ZGU1ZGUwNzNkZTQzZjNiMTVhOTAwM2U1ZTE=
9
+ NjEyNGU5YWRiMTYxY2MxOGY0OWIwZGEyOGRlZWI0M2UzN2FhN2NmNTY5ZDkw
10
+ ZDYyY2ZkOWM3YTAzM2FiYzBlMTI0MmNiMjVmOGI5YmQ0MjZiY2VlZjE5Yjc3
11
+ YzZlYTNhNzIzNmQxMGVlOWY3ZmQ0MjIzMjM4ODQzNjY4NzEyZTY=
12
12
  data.tar.gz: !binary |-
13
- YWE1OTNiMjA2NjFkMWVkYzhmZTkwOGZkYWEzYjQ0NWRmYzJjZmY5ZmYyNzRl
14
- NmNjZjQ1ODhiMzIwZGVhNDQ2ZGMzYmNmNDI2ZWI0ZWRkMTc2NjE5ODRhMjMy
15
- ZjBlODdkODlkMmE1ZWVhNDNlZjIxZjQwNDIyNTgwZGI4MGJhOTE=
13
+ MDA4NTdkNzRlZTBlZDMyYWRkNjRiODJjMzNmOWU1OTI2MzZmMGFjYWFlNWFk
14
+ MzUwMGNjMjNhZDczMGJlMzJkMjg0MDllYzQzYTkzMWVmYmIyODc5NGViNDdi
15
+ N2ExNDMzNGZiNzkzMDY2NjE0ZTFiMDZlYTlhZjc1NTk2ZDEyNGU=
@@ -123,18 +123,21 @@ module ObjectAttorney
123
123
  end
124
124
 
125
125
  def human_attribute_name(attribute_key_name, options = {})
126
- if represented_object_class.respond_to?(:human_attribute_name)
127
- represented_object_class.human_attribute_name(attribute_key_name, options)
128
- else
129
- defaults = []
130
- defaults << "#{represented_object_class.name.underscore}.#{attribute_key_name}" if represented_object_class.present?
131
- defaults << "#{name.underscore}.#{attribute_key_name}"
132
- defaults << options[:default] if options[:default]
133
- defaults.flatten!
134
- defaults << attribute_key_name.to_s.humanize
135
- options[:count] ||= 1
136
- I18n.translate(defaults.shift, options.merge(:default => defaults, :scope => [:activerecord, :attributes]))
126
+ no_translation = "-- no translation --"
127
+
128
+ defaults = ["object_attorney.attributes.#{name.underscore}.#{attribute_key_name}".to_sym]
129
+ defaults << options[:default] if options[:default]
130
+ defaults.flatten!
131
+ defaults << no_translation
132
+ options[:count] ||= 1
133
+
134
+ translation = I18n.translate(defaults.shift, options.merge(default: defaults))
135
+
136
+ if translation == no_translation && represented_object_class.respond_to?(:human_attribute_name)
137
+ translation = represented_object_class.human_attribute_name(attribute_key_name, options)
137
138
  end
139
+
140
+ translation
138
141
  end
139
142
 
140
143
  def model_name
@@ -1,3 +1,3 @@
1
1
  module ObjectAttorney
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.15"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: object_attorney
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Gonçalves
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-04 00:00:00.000000000 Z
11
+ date: 2013-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler