klass_name_types 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,4 +26,34 @@ class KlassNameType < ActiveRecord::Base
26
26
  end
27
27
  end
28
28
 
29
+ class << self
30
+ def from(name)
31
+ case name.class.to_s
32
+ when "String"
33
+ when "Symbol"
34
+ name = name.to_s
35
+ when "Class"
36
+ name = name.to_s
37
+ else
38
+ name = name.class.name
39
+ end
40
+ begin
41
+ return KlassNameType.send(name.methodize)
42
+ rescue Exception => e
43
+ return nil
44
+ end
45
+ end
46
+
47
+ def constantize(id)
48
+ knt = nil
49
+ if id.is_a?(Fixnum)
50
+ knt = KlassNameType.acts_as_constant_get(id)
51
+ else
52
+ knt = KlassNameType.from(id)
53
+ end
54
+ knt.name.constantize unless knt.nil?
55
+ end
56
+
57
+ end
58
+
29
59
  end
@@ -2,4 +2,4 @@
2
2
  gem_name: klass_name_types
3
3
  package: klass_name_types
4
4
  project: magrathea
5
- version: 1.0.8
5
+ version: 1.0.9
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: klass_name_types
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.8
7
- date: 2007-10-23 00:00:00 -04:00
6
+ version: 1.0.9
7
+ date: 2008-01-08 00:00:00 -05:00
8
8
  summary: klass_name_types
9
9
  require_paths:
10
10
  - lib