acts_as_acts_as 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ActsAsActsAs
|
2
|
+
module ActsAsShortcuts
|
3
|
+
def require_methods(*method_list, options = {})
|
4
|
+
method_list.each do |required_method|
|
5
|
+
unless instance_methods.include?(required_method.to_s)
|
6
|
+
raise "Model #{self.to_s} must define #{required_method}"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def require_class_methods(*method_list, options = {})
|
12
|
+
method_list.each do |required_method|
|
13
|
+
unless methods.include?(required_method.to_s)
|
14
|
+
raise "Model #{self.to_s} must define class method #{required_method}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def require_columns(*column_and_type_pairs)
|
20
|
+
column_problems = []
|
21
|
+
column_and_type_pairs.each do |req_colname, req_type|
|
22
|
+
c = columns.find { |c| c.name == req_colname.to_s }
|
23
|
+
if c.nil?
|
24
|
+
column_problems << "Model #{self.to_s} must have column #{req_colname}"
|
25
|
+
next
|
26
|
+
elsif c.type != req_type
|
27
|
+
column_problems << "Column #{req_colname} must have #{req_type} type, has #{c.type}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
raise column_problems.join('; ') unless column_problems.empty?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -38,7 +38,7 @@ class ActsAsActsAs::Requirements::Collector
|
|
38
38
|
end
|
39
39
|
|
40
40
|
module Context
|
41
|
-
[:require_methods, :require_columns, :define_methods, :define_class_methods].each do |x|
|
41
|
+
[:require_methods, :require_class_methods, :require_columns, :define_methods, :define_class_methods].each do |x|
|
42
42
|
define_method(x) { |*args| [x, args] }
|
43
43
|
end
|
44
44
|
end
|
@@ -35,6 +35,28 @@ class ActsAsActsAs::Requirements::Verifier
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
def require_class_methods(options, reqs, *methods)
|
39
|
+
verifier = self
|
40
|
+
acts_as_method = @acts_as_method
|
41
|
+
describe 'required methods' do
|
42
|
+
methods.each do |meth|
|
43
|
+
it "#{meth} must be defined in class" do
|
44
|
+
mod = verifier.tableless_model(
|
45
|
+
:columns => reqs[:require_columns]
|
46
|
+
)
|
47
|
+
reqs[:require_class_methods].reject { |rm| rm == meth }.each do |method|
|
48
|
+
mod.class_eval %{
|
49
|
+
def self.#{method}
|
50
|
+
true
|
51
|
+
end
|
52
|
+
}
|
53
|
+
end
|
54
|
+
lambda { mod.send(acts_as_method, options) }.should raise_error(/#{meth}/)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
38
60
|
def require_columns(options, reqs, *columns)
|
39
61
|
verifier = self
|
40
62
|
acts_as_method = @acts_as_method
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_acts_as
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- phinze
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-26 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- VERSION
|
43
43
|
- acts_as_acts_as.gemspec
|
44
44
|
- lib/acts_as_acts_as.rb
|
45
|
+
- lib/acts_as_acts_as/acts_as_shortcuts.rb
|
45
46
|
- lib/acts_as_acts_as/group_macros.rb
|
46
47
|
- lib/acts_as_acts_as/macros.rb
|
47
48
|
- lib/acts_as_acts_as/requirements.rb
|