dao 3.1.2 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/dao.gemspec +1 -1
- data/lib/dao.rb +2 -2
- data/lib/dao/active_record.rb +43 -14
- metadata +4 -4
data/dao.gemspec
CHANGED
data/lib/dao.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
# dao libs
|
11
11
|
#
|
12
12
|
module Dao
|
13
|
-
Version = '3.
|
13
|
+
Version = '3.2.0' unless defined?(Version)
|
14
14
|
|
15
15
|
def version
|
16
16
|
Dao::Version
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
def dependencies
|
20
20
|
{
|
21
|
-
'map' => ['map' , '~> 4.
|
21
|
+
'map' => ['map' , '~> 4.2.0'],
|
22
22
|
'tagz' => ['tagz' , '~> 9.0.0'],
|
23
23
|
'yajl' => ['yajl-ruby' , '~> 0.8.1']
|
24
24
|
}
|
data/lib/dao/active_record.rb
CHANGED
@@ -42,26 +42,42 @@ if defined?(ActiveRecord)
|
|
42
42
|
options = nil
|
43
43
|
end
|
44
44
|
|
45
|
-
#
|
45
|
+
# get base to_dao from class
|
46
46
|
#
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
47
|
+
base = model.to_dao
|
48
|
+
|
49
|
+
# opts
|
50
|
+
#
|
51
|
+
opts = %w( include includes with exclude excludes without )
|
52
|
+
|
53
|
+
extract_options =
|
54
|
+
proc do |array|
|
55
|
+
last = array.last
|
56
|
+
if last.is_a?(Hash)
|
57
|
+
last = Dao.map(last)
|
58
|
+
if opts.any?{|opt| last.has_key?(opt)}
|
59
|
+
array.pop
|
60
|
+
break(last)
|
61
|
+
end
|
57
62
|
end
|
63
|
+
Map.new
|
58
64
|
end
|
65
|
+
|
66
|
+
# handle case where options are bundled in args...
|
67
|
+
#
|
68
|
+
options ||= extract_options[args]
|
69
|
+
|
70
|
+
# use base options iff none provided
|
71
|
+
#
|
72
|
+
base_options = extract_options[base]
|
73
|
+
if options.blank? and !base_options.blank?
|
74
|
+
options = base_options
|
59
75
|
end
|
60
76
|
|
61
|
-
# refine the
|
77
|
+
# refine the args with includes iff found in options
|
62
78
|
#
|
63
79
|
if options.has_key?(:include) or options.has_key?(:includes) or options.has_key?(:with)
|
64
|
-
args.replace(
|
80
|
+
args.replace(base) if args.empty?
|
65
81
|
args.push(options[:include]) if options[:include]
|
66
82
|
args.push(options[:includes]) if options[:includes]
|
67
83
|
args.push(options[:with]) if options[:with]
|
@@ -69,7 +85,8 @@ if defined?(ActiveRecord)
|
|
69
85
|
|
70
86
|
# take passed in args or model defaults
|
71
87
|
#
|
72
|
-
list = args.empty? ?
|
88
|
+
list = args.empty? ? base : args
|
89
|
+
list = column_names if list.empty?
|
73
90
|
|
74
91
|
# okay - go!
|
75
92
|
#
|
@@ -110,6 +127,18 @@ if defined?(ActiveRecord)
|
|
110
127
|
map[:id] = map[:_id]
|
111
128
|
end
|
112
129
|
|
130
|
+
# refine the map with excludes iff passed as options
|
131
|
+
#
|
132
|
+
if options.has_key?(:exclude) or options.has_key?(:excludes) or options.has_key?(:without)
|
133
|
+
[options[:exclude], options[:excludes], options[:without]].each do |paths|
|
134
|
+
paths = Array(paths)
|
135
|
+
next if paths.blank?
|
136
|
+
paths.each do |path|
|
137
|
+
map.rm(path)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
113
142
|
map
|
114
143
|
end
|
115
144
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dao
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
|
-
- 1
|
9
8
|
- 2
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 3.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ara T. Howard
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-08 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|