acts_as_fu 0.0.4 → 0.0.5
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.
- data/lib/acts_as_fu/base.rb +14 -15
- metadata +4 -3
data/lib/acts_as_fu/base.rb
CHANGED
@@ -21,27 +21,25 @@ module ActsAsFu
|
|
21
21
|
def build_model(name, options={}, &block)
|
22
22
|
connect! unless connected?
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
set_class!(name, super_class, &block)
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def set_class!(name, super_class, &block)
|
35
|
-
klass_name = name.to_s.classify
|
36
|
-
Object.send(:remove_const, klass_name) rescue nil
|
24
|
+
klass_name = name.to_s.classify
|
25
|
+
super_class = options[:superclass] || ActsAsFu::Connection
|
26
|
+
contained = options[:contained] || Object
|
37
27
|
|
28
|
+
contained.send(:remove_const, klass_name) rescue nil
|
38
29
|
klass = Class.new(super_class)
|
39
|
-
|
30
|
+
contained.const_set(klass_name, klass)
|
31
|
+
|
32
|
+
# table_name isn't available until after the class is created.
|
33
|
+
if super_class == ActsAsFu::Connection
|
34
|
+
ActsAsFu::Connection.connection.create_table(klass.table_name, :force => true) { }
|
35
|
+
end
|
40
36
|
|
41
37
|
model_eval(klass, &block)
|
42
38
|
klass
|
43
39
|
end
|
44
40
|
|
41
|
+
private
|
42
|
+
|
45
43
|
def connect!
|
46
44
|
ActsAsFu::Connection.connect!({
|
47
45
|
:adapter => "sqlite3",
|
@@ -57,7 +55,7 @@ module ActsAsFu
|
|
57
55
|
def model_eval(klass, &block)
|
58
56
|
class << klass
|
59
57
|
def method_missing_with_columns(sym, *args, &block)
|
60
|
-
ActsAsFu::Connection.connection.change_table(
|
58
|
+
ActsAsFu::Connection.connection.change_table(table_name) do |t|
|
61
59
|
t.send(sym, *args)
|
62
60
|
end
|
63
61
|
end
|
@@ -71,4 +69,5 @@ module ActsAsFu
|
|
71
69
|
alias_method :method_missing, :method_missing_without_columns
|
72
70
|
end
|
73
71
|
end
|
72
|
+
|
74
73
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Nakajima
|
@@ -31,12 +31,13 @@ extensions: []
|
|
31
31
|
extra_rdoc_files: []
|
32
32
|
|
33
33
|
files:
|
34
|
-
- lib/acts_as_fu
|
35
34
|
- lib/acts-as-fu.rb
|
36
35
|
- lib/acts_as_fu/base.rb
|
37
36
|
- lib/acts_as_fu.rb
|
38
37
|
has_rdoc: true
|
39
38
|
homepage:
|
39
|
+
licenses: []
|
40
|
+
|
40
41
|
post_install_message:
|
41
42
|
rdoc_options: []
|
42
43
|
|
@@ -57,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
58
|
requirements: []
|
58
59
|
|
59
60
|
rubyforge_project:
|
60
|
-
rubygems_version: 1.3.
|
61
|
+
rubygems_version: 1.3.3
|
61
62
|
signing_key:
|
62
63
|
specification_version: 2
|
63
64
|
summary: Generate ActiveRecord models on the fly for your tests
|