klass_name_types 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/init.rb +2 -0
- data/lib/klass_name_type.rb +21 -0
- data/lib/klass_name_types.rb +20 -0
- data/lib/tasks/rubyforge_config.yml +5 -0
- metadata +56 -0
data/init.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "acts_as_constant"
|
2
|
+
class KlassNameType < ActiveRecord::Base
|
3
|
+
acts_as_constant
|
4
|
+
|
5
|
+
validates_presence_of :name
|
6
|
+
validates_uniqueness_of :name
|
7
|
+
validates_length_of :name, :maximum => 100
|
8
|
+
|
9
|
+
def self.create_knt_table
|
10
|
+
begin
|
11
|
+
unless table_exists?
|
12
|
+
puts "klass_name_types table does not exist, so we're going to create the table."
|
13
|
+
ActiveRecord::Base.connection.create_table(:klass_name_types) do |t|
|
14
|
+
t.column :name, :string, :limit => 100, :null => false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
rescue Exception => e
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class << ActiveRecord::Base
|
2
|
+
|
3
|
+
alias_method :ar_inherited, :inherited
|
4
|
+
|
5
|
+
def inherited(child) #:nodoc:
|
6
|
+
c_name = child.to_s
|
7
|
+
begin
|
8
|
+
unless c_name.match("#<Class:")
|
9
|
+
unless KlassNameType.table_exists?
|
10
|
+
KlassNameType.create_knt_table
|
11
|
+
end
|
12
|
+
if KlassNameType.create(:name => c_name)
|
13
|
+
KlassNameType.reload_constants!
|
14
|
+
end
|
15
|
+
end
|
16
|
+
rescue Exception => e
|
17
|
+
end
|
18
|
+
ar_inherited(child)
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.2
|
3
|
+
specification_version: 1
|
4
|
+
name: klass_name_types
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 1.0.0
|
7
|
+
date: 2007-09-13 00:00:00 -04:00
|
8
|
+
summary: klass_name_types
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
- lib
|
12
|
+
- lib
|
13
|
+
- lib/tasks
|
14
|
+
email:
|
15
|
+
homepage:
|
16
|
+
rubyforge_project: magrathea
|
17
|
+
description: "klass_name_types was developed by: markbates"
|
18
|
+
autorequire:
|
19
|
+
- klass_name_types
|
20
|
+
- klass_name_type
|
21
|
+
- klass_name_types
|
22
|
+
- klass_name_type
|
23
|
+
default_executable:
|
24
|
+
bindir: bin
|
25
|
+
has_rdoc: false
|
26
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ">"
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 0.0.0
|
31
|
+
version:
|
32
|
+
platform: ruby
|
33
|
+
signing_key:
|
34
|
+
cert_chain:
|
35
|
+
post_install_message:
|
36
|
+
authors:
|
37
|
+
- markbates
|
38
|
+
files:
|
39
|
+
- init.rb
|
40
|
+
- lib/klass_name_type.rb
|
41
|
+
- lib/klass_name_types.rb
|
42
|
+
- lib/tasks/rubyforge_config.yml
|
43
|
+
test_files: []
|
44
|
+
|
45
|
+
rdoc_options: []
|
46
|
+
|
47
|
+
extra_rdoc_files: []
|
48
|
+
|
49
|
+
executables: []
|
50
|
+
|
51
|
+
extensions: []
|
52
|
+
|
53
|
+
requirements: []
|
54
|
+
|
55
|
+
dependencies: []
|
56
|
+
|