schemaker 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/schemaker/models/base_model.rb +5 -3
- data/lib/schemaker/models.rb +3 -4
- data/schemaker.gemspec +1 -1
- data/spec/schemaker/model/subject_spec.rb +11 -0
- metadata +22 -22
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
@@ -107,9 +107,9 @@ module Schemaker
|
|
107
107
|
# has_and_belongs_to_many :user_accounts, :class_name => 'User'
|
108
108
|
# end
|
109
109
|
#
|
110
|
-
def
|
111
|
-
make_relationship :has_and_belongs_to_many, to_clazz, options
|
112
|
-
|
110
|
+
def create_has_and_belongs_to_many to_clazz, options = {}
|
111
|
+
make_relationship :has_and_belongs_to_many, to_clazz, options.merge(:key => singular_key(to_clazz))
|
112
|
+
models.object_model.make_relationship :has_and_belongs_to_many, my_class, options.merge(:key => singular_key(my_class))
|
113
113
|
end
|
114
114
|
|
115
115
|
# Creates a given type of relationship
|
@@ -122,6 +122,8 @@ module Schemaker
|
|
122
122
|
opts_str = options.empty? ? '' : options.inspect.insert(0, ', ').gsub(/[{}]/ , '')
|
123
123
|
log "#{my_class_name}.#{relationship_name} :#{key_name}#{opts_str}" if log_on?
|
124
124
|
|
125
|
+
puts "keyname: #{key_name}"
|
126
|
+
|
125
127
|
return my_class.send(relationship_name, key_name) if options.empty?
|
126
128
|
|
127
129
|
my_class.send(relationship_name, key_name, options)
|
data/lib/schemaker/models.rb
CHANGED
@@ -31,11 +31,10 @@ module Schemaker
|
|
31
31
|
def initialize subject_class, object_class, join_class, options = {}
|
32
32
|
raise ArgumentError, "subject class not given" if !subject_class
|
33
33
|
raise ArgumentError, "object class not given" if !object_class
|
34
|
-
raise ArgumentError, "join class not given" if !join_class
|
35
34
|
|
36
35
|
@subject_model = SubjectModel.new self, subject_class, options[:subject_key]
|
37
36
|
@object_model = ObjectModel.new self, object_class
|
38
|
-
@join_model = JoinModel.new
|
37
|
+
@join_model = JoinModel.new(self, join_class) if join_class
|
39
38
|
end
|
40
39
|
|
41
40
|
# creates a key for a given type
|
@@ -46,8 +45,8 @@ module Schemaker
|
|
46
45
|
|
47
46
|
# configure each model in turn
|
48
47
|
def configure
|
49
|
-
[subject_model, object_model, join_model].each do
|
50
|
-
|
48
|
+
[subject_model, object_model, join_model].compact.each do |model|
|
49
|
+
model.configure
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
data/schemaker.gemspec
CHANGED
@@ -22,4 +22,15 @@ describe subject_model_class do
|
|
22
22
|
matches_all last_log, 'UserAccount.has_many :troles', ':through=>:user_roles', ':source=>:role', ':class_name=>"Role"', ':foreign_key=>:account_id'
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
describe '#quick_join' do
|
27
|
+
it 'should configure subject model using a quick join :has_and_belongs_to_many' do
|
28
|
+
subject_model.quick_join
|
29
|
+
|
30
|
+
# check the logs!
|
31
|
+
first_log = subject_model.logs.first
|
32
|
+
|
33
|
+
matches_all first_log, 'has_and_belongs_to_many :roles'
|
34
|
+
end
|
35
|
+
end
|
25
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schemaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-12 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sweetloader
|
16
|
-
requirement: &
|
16
|
+
requirement: &2162469820 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.1.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2162469820
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activerecord
|
27
|
-
requirement: &
|
27
|
+
requirement: &2162469100 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.1
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2162469100
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &2162356580 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.6.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2162356580
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: database_cleaner
|
49
|
-
requirement: &
|
49
|
+
requirement: &2162355880 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.6.8
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2162355880
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: sqlite3
|
60
|
-
requirement: &
|
60
|
+
requirement: &2162355200 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2162355200
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: cutter
|
71
|
-
requirement: &
|
71
|
+
requirement: &2162354540 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2162354540
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: bundler
|
82
|
-
requirement: &
|
82
|
+
requirement: &2162353920 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '1'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2162353920
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: jeweler
|
93
|
-
requirement: &
|
93
|
+
requirement: &2162353220 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '1.6'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2162353220
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rcov
|
104
|
-
requirement: &
|
104
|
+
requirement: &2162352400 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *2162352400
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: yard
|
115
|
-
requirement: &
|
115
|
+
requirement: &2162351700 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,7 +120,7 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *2162351700
|
124
124
|
description: Configures relationships between subject, join and object model for a
|
125
125
|
given behavior
|
126
126
|
email: kmandrup@gmail.com
|
@@ -169,7 +169,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
169
169
|
version: '0'
|
170
170
|
segments:
|
171
171
|
- 0
|
172
|
-
hash:
|
172
|
+
hash: -1992204561229499507
|
173
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
174
|
none: false
|
175
175
|
requirements:
|