link2 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.model_name.human rescue resource_class.human_name).downcase : resource.to_s
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.model_name.human rescue resource_class.human_name).downcase if custom_name.blank?
297
+ custom_name = ::Link2::Support.human_name_for(resource_class).downcase if custom_name.blank?
298
298
  custom_name
299
299
  end
300
300
 
@@ -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.human_name rescue resource_class.to_s.humanize
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
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Link2
4
- VERSION = "0.1.8".freeze
4
+ VERSION = "0.1.9".freeze
5
5
  end
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: 11
4
+ hash: 9
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 8
10
- version: 0.1.8
9
+ - 9
10
+ version: 0.1.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jonas Grimfelt