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 CHANGED
@@ -1 +1 @@
1
- 0.1.2
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 has_and_belongs_many to_clazz, options = {}
111
- make_relationship :has_and_belongs_to_many, to_clazz, options[:from]
112
- to_clazz.make_relationship :has_and_belongs_to_many, my_class, options[:to]
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)
@@ -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 self, join_class
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
- |model| model.configure
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "schemaker"
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
@@ -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.2
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: &2157347720 !ruby/object:Gem::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: *2157347720
24
+ version_requirements: *2162469820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activerecord
27
- requirement: &2157346060 !ruby/object:Gem::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: *2157346060
35
+ version_requirements: *2162469100
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2157342600 !ruby/object:Gem::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: *2157342600
46
+ version_requirements: *2162356580
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: database_cleaner
49
- requirement: &2157340920 !ruby/object:Gem::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: *2157340920
57
+ version_requirements: *2162355880
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: sqlite3
60
- requirement: &2157338840 !ruby/object:Gem::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: *2157338840
68
+ version_requirements: *2162355200
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: cutter
71
- requirement: &2157337240 !ruby/object:Gem::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: *2157337240
79
+ version_requirements: *2162354540
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: bundler
82
- requirement: &2157336480 !ruby/object:Gem::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: *2157336480
90
+ version_requirements: *2162353920
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: jeweler
93
- requirement: &2157334900 !ruby/object:Gem::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: *2157334900
101
+ version_requirements: *2162353220
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rcov
104
- requirement: &2157333940 !ruby/object:Gem::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: *2157333940
112
+ version_requirements: *2162352400
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: yard
115
- requirement: &2157332720 !ruby/object:Gem::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: *2157332720
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: 2528253751213112279
172
+ hash: -1992204561229499507
173
173
  required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  none: false
175
175
  requirements: