link2 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/link2/brain.rb +2 -2
- data/lib/link2/i18n.rb +1 -1
- data/lib/link2/support.rb +14 -0
- data/lib/link2/version.rb +1 -1
- metadata +3 -3
data/lib/link2/brain.rb
CHANGED
@@ -292,9 +292,9 @@ module Link2
|
|
292
292
|
|
293
293
|
if ::Link2::Support.record_object?(resource)
|
294
294
|
# Skip any ugly default to_s-value:
|
295
|
-
custom_name = resource.to_s =~ CLASS_INSTANCE_STRING ? (resource_class
|
295
|
+
custom_name = resource.to_s =~ CLASS_INSTANCE_STRING ? ::Link2::Support.human_name_for(resource_class).downcase : resource.to_s
|
296
296
|
end
|
297
|
-
custom_name = (resource_class
|
297
|
+
custom_name = ::Link2::Support.human_name_for(resource_class).downcase if custom_name.blank?
|
298
298
|
custom_name
|
299
299
|
end
|
300
300
|
|
data/lib/link2/i18n.rb
CHANGED
@@ -96,7 +96,7 @@ module Link2
|
|
96
96
|
#
|
97
97
|
def localized_resource_class_name(resource)
|
98
98
|
resource_class = ::Link2::Support.find_resource_class(resource)
|
99
|
-
resource_name = resource_class
|
99
|
+
resource_name = ::Link2::Support.human_name_for(resource_class) rescue resource_class.to_s.humanize
|
100
100
|
resource_name.underscore
|
101
101
|
end
|
102
102
|
|
data/lib/link2/support.rb
CHANGED
@@ -132,6 +132,20 @@ module Link2
|
|
132
132
|
def record_object?(object)
|
133
133
|
object.respond_to?(:new_record?)
|
134
134
|
end
|
135
|
+
|
136
|
+
# Get the human name for an object/class - in both Rails 2.3 and Rails 3.
|
137
|
+
#
|
138
|
+
# == Usage/Examples:
|
139
|
+
#
|
140
|
+
# human_name_for(CoolStuff)
|
141
|
+
#
|
142
|
+
# # => "Cool stuff"
|
143
|
+
#
|
144
|
+
# ...or something like that.
|
145
|
+
#
|
146
|
+
def human_name_for(object)
|
147
|
+
object.model_name.human rescue object.human_name
|
148
|
+
end
|
135
149
|
end
|
136
150
|
|
137
151
|
end
|
data/lib/link2/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: link2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 9
|
10
|
+
version: 0.1.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jonas Grimfelt
|