orm_adapter 0.4.1 → 0.5.0
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.
- checksums.yaml +4 -4
- data/History.txt +5 -0
- data/lib/orm_adapter/adapters/active_record.rb +12 -4
- data/lib/orm_adapter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c94ff61c9aabbe1129b7037d1187a29e803ebb52
|
4
|
+
data.tar.gz: cf04bc145952fb582c6015a9b85d0129d2d801cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdadd8d9a6cd0483802fc6c4f6865dd2647842c1ddbde7e078efdb413b23b98228a55c9fc95620d73029dbdfe9a3706e31371b1325d6b77eb4da612001c9f137
|
7
|
+
data.tar.gz: 9af572ba4d45256586ec8b0c49ef1e23fb55a646045c268a9cdaa02f0143539678c477fd25f6b2bd5a84f3f7e3bc8644652e0b16a854fafd7977443472953814
|
data/History.txt
CHANGED
@@ -19,14 +19,12 @@ module OrmAdapter
|
|
19
19
|
|
20
20
|
# @see OrmAdapter::Base#find_first
|
21
21
|
def find_first(options = {})
|
22
|
-
|
23
|
-
klass.where(conditions_to_fields(conditions)).order(*order_clause(order)).first
|
22
|
+
construct_relation(klass, options).first
|
24
23
|
end
|
25
24
|
|
26
25
|
# @see OrmAdapter::Base#find_all
|
27
26
|
def find_all(options = {})
|
28
|
-
|
29
|
-
klass.where(conditions_to_fields(conditions)).order(*order_clause(order)).limit(limit).offset(offset)
|
27
|
+
construct_relation(klass, options)
|
30
28
|
end
|
31
29
|
|
32
30
|
# @see OrmAdapter::Base#create!
|
@@ -40,6 +38,16 @@ module OrmAdapter
|
|
40
38
|
end
|
41
39
|
|
42
40
|
protected
|
41
|
+
def construct_relation(relation, options)
|
42
|
+
conditions, order, limit, offset = extract_conditions!(options)
|
43
|
+
|
44
|
+
relation = relation.where(conditions_to_fields(conditions))
|
45
|
+
relation = relation.order(order_clause(order)) if order.any?
|
46
|
+
relation = relation.limit(limit) if limit
|
47
|
+
relation = relation.offset(offset) if offset
|
48
|
+
|
49
|
+
relation
|
50
|
+
end
|
43
51
|
|
44
52
|
# Introspects the klass to convert and objects in conditions into foreign key and type fields
|
45
53
|
def conditions_to_fields(conditions)
|
data/lib/orm_adapter/version.rb
CHANGED