orm_adapter 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -6
- data/lib/orm_adapter/adapters/active_record.rb +16 -14
- data/lib/orm_adapter/version.rb +1 -1
- metadata +29 -29
data/History.txt
CHANGED
@@ -1,22 +1,27 @@
|
|
1
|
+
== 0.0.7
|
2
|
+
|
3
|
+
* Lazy load Active Record [José Valim]
|
4
|
+
|
5
|
+
|
1
6
|
== 0.0.6
|
2
7
|
|
3
|
-
*
|
8
|
+
* Active Record 3.1 association compatibility [Ian White]
|
4
9
|
* Compatibility with mongoid master wrt. OrmAdapter::Base#get [Frank Wöckener]. Closes #9 [Ian White]
|
5
10
|
|
6
11
|
|
7
12
|
== 0.0.5
|
8
|
-
|
13
|
+
|
9
14
|
* Adds Mongo Mapper adapter [Luke Cunningham]
|
10
|
-
|
15
|
+
|
11
16
|
|
12
17
|
== 0.0.4
|
13
|
-
|
18
|
+
|
14
19
|
* Adds ability to order results from #find_first and #find_all [Ian White]
|
15
20
|
* Rationalise development dependencies and release process [Ian White]
|
16
|
-
|
21
|
+
|
17
22
|
|
18
23
|
== 0.0.3
|
19
|
-
|
24
|
+
|
20
25
|
* ActiveRecord's OrmAdapter handles non standard foreign key names [Ian White]
|
21
26
|
* fix ruby 1.9.2 problems. [Ian White]
|
22
27
|
- removes "can't add a new key into hash during iteration" problem with ActiveRecord OrmAdapter
|
@@ -4,11 +4,8 @@ rescue LoadError
|
|
4
4
|
require 'active_record'
|
5
5
|
end
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
class OrmAdapter < ::OrmAdapter::Base
|
11
|
-
|
7
|
+
module OrmAdapter
|
8
|
+
class ActiveRecord < Base
|
12
9
|
# Do not consider these to be part of the class list
|
13
10
|
def self.except_classes
|
14
11
|
@@except_classes ||= [
|
@@ -56,37 +53,42 @@ class ActiveRecord::Base
|
|
56
53
|
conditions, order = extract_conditions_and_order!(options)
|
57
54
|
klass.all :conditions => conditions_to_fields(conditions), :order => order_clause(order)
|
58
55
|
end
|
59
|
-
|
56
|
+
|
60
57
|
# @see OrmAdapter::Base#create!
|
61
58
|
def create!(attributes)
|
62
59
|
klass.create!(attributes)
|
63
60
|
end
|
64
|
-
|
61
|
+
|
65
62
|
protected
|
66
63
|
|
67
64
|
# Introspects the klass to convert and objects in conditions into foreign key and type fields
|
68
65
|
def conditions_to_fields(conditions)
|
69
66
|
fields = {}
|
70
67
|
conditions.each do |key, value|
|
71
|
-
if value.is_a?(ActiveRecord::Base) && (assoc = klass.reflect_on_association(key.to_sym)) && assoc.belongs_to?
|
72
|
-
|
73
|
-
if ActiveRecord::VERSION::STRING < "3.1"
|
74
|
-
fields[assoc.primary_key_name] = value.send(value.class.primary_key)
|
68
|
+
if value.is_a?(::ActiveRecord::Base) && (assoc = klass.reflect_on_association(key.to_sym)) && assoc.belongs_to?
|
69
|
+
|
70
|
+
if ::ActiveRecord::VERSION::STRING < "3.1"
|
71
|
+
fields[assoc.primary_key_name] = value.send(value.class.primary_key)
|
75
72
|
fields[assoc.options[:foreign_type]] = value.class.base_class.name.to_s if assoc.options[:polymorphic]
|
76
73
|
else # >= 3.1
|
77
|
-
fields[assoc.foreign_key] = value.send(value.class.primary_key)
|
74
|
+
fields[assoc.foreign_key] = value.send(value.class.primary_key)
|
78
75
|
fields[assoc.foreign_type] = value.class.base_class.name.to_s if assoc.options[:polymorphic]
|
79
76
|
end
|
80
|
-
|
77
|
+
|
81
78
|
else
|
82
79
|
fields[key] = value
|
83
80
|
end
|
84
81
|
end
|
85
82
|
fields
|
86
83
|
end
|
87
|
-
|
84
|
+
|
88
85
|
def order_clause(order)
|
89
86
|
order.map {|pair| "#{pair[0]} #{pair[1]}"}.join(",")
|
90
87
|
end
|
91
88
|
end
|
92
89
|
end
|
90
|
+
|
91
|
+
ActiveSupport.on_load(:active_record) do
|
92
|
+
extend ::OrmAdapter::ToAdapter
|
93
|
+
self::OrmAdapter = ::OrmAdapter::ActiveRecord
|
94
|
+
end
|
data/lib/orm_adapter/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orm_adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-03-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
17
|
-
requirement: &
|
17
|
+
requirement: &2157226320 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 1.0.0
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2157226320
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: git
|
28
|
-
requirement: &
|
28
|
+
requirement: &2157225580 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 1.2.5
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2157225580
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: yard
|
39
|
-
requirement: &
|
39
|
+
requirement: &2157224780 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 0.6.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2157224780
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rake
|
50
|
-
requirement: &
|
50
|
+
requirement: &2157224140 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 0.8.7
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2157224140
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: activerecord
|
61
|
-
requirement: &
|
61
|
+
requirement: &2157223380 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: 3.0.0
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2157223380
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: mongoid
|
72
|
-
requirement: &
|
72
|
+
requirement: &2157222660 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 2.0.0.beta.20
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *2157222660
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: mongo_mapper
|
83
|
-
requirement: &
|
83
|
+
requirement: &2157208000 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: 0.9.0
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *2157208000
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: bson_ext
|
94
|
-
requirement: &
|
94
|
+
requirement: &2157204220 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ! '>='
|
@@ -99,10 +99,10 @@ dependencies:
|
|
99
99
|
version: 1.3.0
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *2157204220
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: rspec
|
105
|
-
requirement: &
|
105
|
+
requirement: &2157203000 !ruby/object:Gem::Requirement
|
106
106
|
none: false
|
107
107
|
requirements:
|
108
108
|
- - ! '>='
|
@@ -110,10 +110,10 @@ dependencies:
|
|
110
110
|
version: 2.4.0
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
|
-
version_requirements: *
|
113
|
+
version_requirements: *2157203000
|
114
114
|
- !ruby/object:Gem::Dependency
|
115
115
|
name: sqlite3-ruby
|
116
|
-
requirement: &
|
116
|
+
requirement: &2157201880 !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|
119
119
|
- - ! '>='
|
@@ -121,10 +121,10 @@ dependencies:
|
|
121
121
|
version: 1.3.2
|
122
122
|
type: :development
|
123
123
|
prerelease: false
|
124
|
-
version_requirements: *
|
124
|
+
version_requirements: *2157201880
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: datamapper
|
127
|
-
requirement: &
|
127
|
+
requirement: &2157201200 !ruby/object:Gem::Requirement
|
128
128
|
none: false
|
129
129
|
requirements:
|
130
130
|
- - ! '>='
|
@@ -132,10 +132,10 @@ dependencies:
|
|
132
132
|
version: '1.0'
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
|
-
version_requirements: *
|
135
|
+
version_requirements: *2157201200
|
136
136
|
- !ruby/object:Gem::Dependency
|
137
137
|
name: dm-sqlite-adapter
|
138
|
-
requirement: &
|
138
|
+
requirement: &2157199880 !ruby/object:Gem::Requirement
|
139
139
|
none: false
|
140
140
|
requirements:
|
141
141
|
- - ! '>='
|
@@ -143,10 +143,10 @@ dependencies:
|
|
143
143
|
version: '1.0'
|
144
144
|
type: :development
|
145
145
|
prerelease: false
|
146
|
-
version_requirements: *
|
146
|
+
version_requirements: *2157199880
|
147
147
|
- !ruby/object:Gem::Dependency
|
148
148
|
name: dm-active_model
|
149
|
-
requirement: &
|
149
|
+
requirement: &2157197540 !ruby/object:Gem::Requirement
|
150
150
|
none: false
|
151
151
|
requirements:
|
152
152
|
- - ! '>='
|
@@ -154,7 +154,7 @@ dependencies:
|
|
154
154
|
version: '1.0'
|
155
155
|
type: :development
|
156
156
|
prerelease: false
|
157
|
-
version_requirements: *
|
157
|
+
version_requirements: *2157197540
|
158
158
|
description: Provides a single point of entry for using basic features of ruby ORMs
|
159
159
|
email: ian.w.white@gmail.com
|
160
160
|
executables: []
|
@@ -205,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
205
|
version: 1.3.6
|
206
206
|
requirements: []
|
207
207
|
rubyforge_project: orm_adapter
|
208
|
-
rubygems_version: 1.8.
|
208
|
+
rubygems_version: 1.8.15
|
209
209
|
signing_key:
|
210
210
|
specification_version: 3
|
211
211
|
summary: orm_adapter provides a single point of entry for using basic features of
|