mongomatic 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -11,9 +11,9 @@ Mongomatic allows you to map your Ruby objects to Mongo documents. It is designe
11
11
  end
12
12
 
13
13
  # set the db settings for all models:
14
- Mongomatic.settings = { :connection => ["localhost", 27017, {}], :db => "mongomatic_test" }
14
+ Mongomatic.db = Mongo::Connection.new.db("mongomatic_test")
15
15
  # or you can set it for a specific model:
16
- User.settings = { :connection => ["localhost", 27017, {}], :db => "mongomatic_test_user" }
16
+ User.db = Mongo::Connection.new.db("mongomatic_test_user")
17
17
 
18
18
  u = User.new(:name => "Ben")
19
19
  => #<User:0x00000100d0cbf8 @doc={"name"=>"Ben"}, @removed=false>
@@ -4,21 +4,14 @@ module Mongomatic
4
4
  include Mongomatic::Validatable
5
5
 
6
6
  class << self
7
- def settings
8
- @settings || Mongomatic.settings
9
- end
10
-
11
- def settings=(hash)
12
- @settings = hash
13
- reconnect!; hash
14
- end
15
-
16
- def reconnect!
17
- @db = @collection = nil; true
7
+ def db
8
+ @db || Mongomatic.db || raise(ArgumentError, "No db supplied")
18
9
  end
19
10
 
20
- def db
21
- @db ||= Mongo::Connection.new(*self.settings[:connection]).db(self.settings[:db])
11
+ def db=(obj)
12
+ unless obj.is_a?(Mongo::DB)
13
+ raise(ArgumentError, "Must supply a Mongo::DB object")
14
+ end; @db = obj
22
15
  end
23
16
 
24
17
  def collection_name
data/lib/mongomatic.rb CHANGED
@@ -1,6 +1,6 @@
1
- gem "bson", ">= 1.0.3"
2
- gem "bson_ext", ">= 1.0.1"
3
- gem "mongo", ">= 1.0.3"
1
+ gem "bson", ">= 1.0.4"
2
+ gem "bson_ext", ">= 1.0.4"
3
+ gem "mongo", ">= 1.0.7"
4
4
  gem "activesupport", ">= 2.3.5"
5
5
 
6
6
  require "bson"
@@ -15,14 +15,14 @@ end
15
15
 
16
16
  module Mongomatic
17
17
  class << self
18
- def settings
19
- @settings || { :connection => ["localhost", 27017, {}], :db => "main" }
18
+ def db
19
+ @db
20
20
  end
21
-
22
- def settings=(hash)
23
- @settings = hash
24
- @db = @collection = nil
25
- hash
21
+
22
+ def db=(obj)
23
+ unless obj.is_a?(Mongo::DB)
24
+ raise(ArgumentError, "Must supply a Mongo::DB object")
25
+ end; @db = obj
26
26
  end
27
27
  end
28
28
  end
data/test/helper.rb CHANGED
@@ -7,7 +7,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
7
  $LOAD_PATH.unshift(File.dirname(__FILE__))
8
8
  require 'mongomatic'
9
9
 
10
- Mongomatic.settings = { :connection => ["localhost", 27017, {}], :db => "mongomatic_test" }
10
+ Mongomatic.db = Mongo::Connection.new.db("mongomatic_test")
11
11
 
12
12
  class Person < Mongomatic::Base
13
13
  validates_presence_of :name
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 1
7
8
  - 0
8
- - 9
9
- version: 0.0.9
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ben Myles
@@ -14,13 +14,14 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-11 00:00:00 -07:00
17
+ date: 2010-08-12 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: shoulda
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
@@ -35,48 +36,52 @@ dependencies:
35
36
  name: bson
36
37
  prerelease: false
37
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
38
40
  requirements:
39
41
  - - ">="
40
42
  - !ruby/object:Gem::Version
41
43
  segments:
42
44
  - 1
43
45
  - 0
44
- - 3
45
- version: 1.0.3
46
+ - 4
47
+ version: 1.0.4
46
48
  type: :runtime
47
49
  version_requirements: *id002
48
50
  - !ruby/object:Gem::Dependency
49
51
  name: bson_ext
50
52
  prerelease: false
51
53
  requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
52
55
  requirements:
53
56
  - - ">="
54
57
  - !ruby/object:Gem::Version
55
58
  segments:
56
59
  - 1
57
60
  - 0
58
- - 1
59
- version: 1.0.1
61
+ - 4
62
+ version: 1.0.4
60
63
  type: :runtime
61
64
  version_requirements: *id003
62
65
  - !ruby/object:Gem::Dependency
63
66
  name: mongo
64
67
  prerelease: false
65
68
  requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
66
70
  requirements:
67
71
  - - ">="
68
72
  - !ruby/object:Gem::Version
69
73
  segments:
70
74
  - 1
71
75
  - 0
72
- - 3
73
- version: 1.0.3
76
+ - 7
77
+ version: 1.0.7
74
78
  type: :runtime
75
79
  version_requirements: *id004
76
80
  - !ruby/object:Gem::Dependency
77
81
  name: activesupport
78
82
  prerelease: false
79
83
  requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
80
85
  requirements:
81
86
  - - ">="
82
87
  - !ruby/object:Gem::Version
@@ -125,6 +130,8 @@ files:
125
130
  - lib/mongomatic/validatable/validations/validation_base.rb
126
131
  - LICENSE
127
132
  - README.rdoc
133
+ - test/helper.rb
134
+ - test/test_mongomatic.rb
128
135
  has_rdoc: true
129
136
  homepage: http://github.com/benmyles/mongomatic
130
137
  licenses: []
@@ -135,6 +142,7 @@ rdoc_options:
135
142
  require_paths:
136
143
  - lib
137
144
  required_ruby_version: !ruby/object:Gem::Requirement
145
+ none: false
138
146
  requirements:
139
147
  - - ">="
140
148
  - !ruby/object:Gem::Version
@@ -142,6 +150,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
150
  - 0
143
151
  version: "0"
144
152
  required_rubygems_version: !ruby/object:Gem::Requirement
153
+ none: false
145
154
  requirements:
146
155
  - - ">="
147
156
  - !ruby/object:Gem::Version
@@ -151,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
160
  requirements: []
152
161
 
153
162
  rubyforge_project:
154
- rubygems_version: 1.3.6
163
+ rubygems_version: 1.3.7
155
164
  signing_key:
156
165
  specification_version: 3
157
166
  summary: Mongomatic is a simple Ruby object mapper for Mongo