dao 3.1.2 → 3.2.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.
Files changed (4) hide show
  1. data/dao.gemspec +1 -1
  2. data/lib/dao.rb +2 -2
  3. data/lib/dao/active_record.rb +43 -14
  4. metadata +4 -4
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "dao"
6
- spec.version = "3.1.2"
6
+ spec.version = "3.2.0"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "dao"
9
9
  spec.description = "description: dao kicks the ass"
data/lib/dao.rb CHANGED
@@ -10,7 +10,7 @@
10
10
  # dao libs
11
11
  #
12
12
  module Dao
13
- Version = '3.1.2' unless defined?(Version)
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.1.0'],
21
+ 'map' => ['map' , '~> 4.2.0'],
22
22
  'tagz' => ['tagz' , '~> 9.0.0'],
23
23
  'yajl' => ['yajl-ruby' , '~> 0.8.1']
24
24
  }
@@ -42,26 +42,42 @@ if defined?(ActiveRecord)
42
42
  options = nil
43
43
  end
44
44
 
45
- # search for options inside args...
45
+ # get base to_dao from class
46
46
  #
47
- if options.nil?
48
- last = args.last
49
- options = Dao.map
50
-
51
- if last.is_a?(Hash)
52
- last = Dao.map(last)
53
- keys = %w( include includes with )
54
- if keys.any?{|key| last.has_key?(key)}
55
- options.update(last)
56
- args.pop
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 list with includes iff passed as options
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(model.to_dao) if args.empty?
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? ? model.to_dao : args
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: 7
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
- - 1
9
8
  - 2
10
- version: 3.1.2
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-07 00:00:00 -06:00
18
+ date: 2011-06-08 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies: []
21
21