mongomapper_plugins 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,8 @@
1
1
  module MongoMapper
2
2
  module Plugins
3
3
  module AutoIncrementId
4
+ extend ActiveSupport::Concern
5
+
4
6
  module ClassMethods
5
7
  def auto_increment_id
6
8
  key :_id, Integer
@@ -23,14 +25,8 @@ module MongoMapper
23
25
  end
24
26
  end
25
27
  end
26
-
27
- module Addition
28
- def self.included(model)
29
- model.plugin AutoIncrementId
30
- end
31
- end
32
28
  end
33
29
  end
34
30
  end
35
31
 
36
- MongoMapper::Document.append_inclusions MongoMapper::Plugins::AutoIncrementId::Addition
32
+ MongoMapper::Document.plugin MongoMapper::Plugins::AutoIncrementId
@@ -1,6 +1,8 @@
1
1
  module MongoMapper
2
2
  module Plugins
3
3
  module UpdatingModifiers
4
+ extend ActiveSupport::Concern
5
+
4
6
  def self.configure(mod)
5
7
  end
6
8
 
@@ -10,7 +12,7 @@ module MongoMapper
10
12
  obj, method = get_obj_and_method(key)
11
13
  obj.send("#{method}=", value)
12
14
  end
13
- super
15
+ super hash_to_mongo(hash)
14
16
  end
15
17
 
16
18
  def increment(hash)
@@ -19,7 +21,7 @@ module MongoMapper
19
21
  val = obj.send(method)
20
22
  obj.send("#{method}=", val + value)
21
23
  end
22
- super
24
+ super hash_to_mongo(hash)
23
25
  end
24
26
 
25
27
  def decrement(hash)
@@ -28,7 +30,7 @@ module MongoMapper
28
30
  val = obj.send(method)
29
31
  obj.send("#{method}=", val - value)
30
32
  end
31
- super
33
+ super hash_to_mongo(hash)
32
34
  end
33
35
 
34
36
  def push(hash)
@@ -37,7 +39,7 @@ module MongoMapper
37
39
  obj = obj.send(method)
38
40
  obj.push value
39
41
  end
40
- super
42
+ super hash_to_mongo(hash)
41
43
  end
42
44
 
43
45
  def pull(hash)
@@ -46,7 +48,7 @@ module MongoMapper
46
48
  obj = obj.send(method)
47
49
  obj.delete_if { |e| e == value }
48
50
  end
49
- super
51
+ super hash_to_mongo(hash)
50
52
  end
51
53
 
52
54
  def add_to_set(hash)
@@ -55,7 +57,7 @@ module MongoMapper
55
57
  obj = obj.send(method)
56
58
  obj.push(value) unless obj.include?(value)
57
59
  end
58
- super
60
+ super hash_to_mongo(hash)
59
61
  end
60
62
  alias push_uniq add_to_set
61
63
 
@@ -71,12 +73,18 @@ module MongoMapper
71
73
 
72
74
  [obj, method]
73
75
  end
74
- end
75
76
 
76
- module Addition
77
- def self.included(model)
78
- model.plugin UpdatingModifiers
79
- end
77
+ def hash_to_mongo(arg)
78
+ if arg.is_a?(Hash)
79
+ keys = arg.keys
80
+ keys.each do |k|
81
+ arg[k] = hash_to_mongo(arg[k])
82
+ end
83
+ arg
84
+ else
85
+ arg && arg.respond_to?(:to_mongo) ? arg.to_mongo : arg
86
+ end
87
+ end
80
88
  end
81
89
  end
82
90
  end
@@ -1,6 +1,8 @@
1
1
  module MongoMapper
2
2
  module Plugins
3
3
  module VersionedUpdate
4
+ extend ActiveSupport::Concern
5
+
4
6
  module ClassMethods
5
7
  def versioned_update
6
8
  include MongoMapper::Plugins::VersionedUpdate::OverriddenMethods
metadata CHANGED
@@ -1,39 +1,36 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mongomapper_plugins
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
4
5
  prerelease:
5
- version: 0.0.6
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Andrew Timberlake
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-02-28 00:00:00 +02:00
12
+ date: 2011-02-28 00:00:00.000000000 +02:00
14
13
  default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
17
16
  name: bundler
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2153202020 !ruby/object:Gem::Requirement
20
18
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: "1.0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '1.0'
25
23
  type: :development
26
- version_requirements: *id001
24
+ prerelease: false
25
+ version_requirements: *2153202020
27
26
  description: A repository of MongoMapper plugins.
28
27
  email: andrew@andrewtimberlake.com
29
28
  executables: []
30
-
31
29
  extensions: []
32
-
33
- extra_rdoc_files:
30
+ extra_rdoc_files:
34
31
  - LICENSE
35
32
  - README.rdoc
36
- files:
33
+ files:
37
34
  - LICENSE
38
35
  - lib/mongo_mapper/plugins/auto_increment_id.rb
39
36
  - lib/mongo_mapper/plugins/updating_modifiers.rb
@@ -44,30 +41,27 @@ files:
44
41
  has_rdoc: true
45
42
  homepage: http://github.com/andrewtimberlake/mongomapper_plugins
46
43
  licenses: []
47
-
48
44
  post_install_message:
49
- rdoc_options:
45
+ rdoc_options:
50
46
  - --charset=UTF-8
51
- require_paths:
47
+ require_paths:
52
48
  - lib
53
- required_ruby_version: !ruby/object:Gem::Requirement
49
+ required_ruby_version: !ruby/object:Gem::Requirement
54
50
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- version: "0"
59
- required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
56
  none: false
61
- requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: "0"
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
65
61
  requirements: []
66
-
67
62
  rubyforge_project:
68
- rubygems_version: 1.5.2
63
+ rubygems_version: 1.6.2
69
64
  signing_key:
70
65
  specification_version: 3
71
66
  summary: A repository of MongoMapper plugins.
72
67
  test_files: []
73
-