mongo_adaptor 0.0.5 → 0.0.6

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.
data/lib/mongo_adaptor.rb CHANGED
@@ -38,7 +38,7 @@ class MongoAdaptor
38
38
  @klass.new.tap do |model|
39
39
  model[:id] = result.delete('_id') if model.respond_to?(:id)
40
40
  result.each do |field,value|
41
- model[field] = value if model.members.map(&:to_s).include?(field.to_s)
41
+ model[field] = value if model.class.members.map(&:to_s).include?(field.to_s)
42
42
  end
43
43
  end
44
44
  end
@@ -1,3 +1,3 @@
1
1
  class MongoAdaptor
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -15,12 +15,12 @@ describe 'adapting structs into mongo' do
15
15
  end
16
16
 
17
17
  describe 'useing the adaptor' do
18
- let(:klass) { Struct.new :name, :other, :id }
18
+ let(:klass) { Struct.new :name, :other, :members, :id }
19
19
  let(:adaptor) { MongoAdaptor.new 'test_collection', klass }
20
20
  let(:collection) { Mongo::Configure.current.load.collection 'test_collection' }
21
21
 
22
22
  describe 'with a new model' do
23
- let(:model) { klass.new 'Test Model','Some Data','fake key' }
23
+ let(:model) { klass.new 'Test Model','Some Data','Some Members','fake key' }
24
24
  let(:data) { collection.find({}).to_a[-1] }
25
25
 
26
26
  shared_examples_for 'new model' do
@@ -36,6 +36,7 @@ describe 'adapting structs into mongo' do
36
36
  subject
37
37
  data['name'].should == 'Test Model'
38
38
  data['other'].should == 'Some Data'
39
+ data['members'].should == 'Some Members'
39
40
  end
40
41
  end
41
42
 
@@ -50,8 +51,8 @@ describe 'adapting structs into mongo' do
50
51
  end
51
52
 
52
53
  describe 'with an existing model' do
53
- let(:model) { klass.new 'Test Model','Some Data' }
54
- let(:id) { collection.insert({ :name => 'My Model', :other => 'Some Value' },{ :safe => true }) }
54
+ let(:model) { klass.new 'Test Model','Some Data','Some Members' }
55
+ let(:id) { collection.insert({ :name => 'My Model', :other => 'Some Value', :members => 'Some Members' },{ :safe => true }) }
55
56
 
56
57
  before do
57
58
  model.id = id
@@ -71,6 +72,7 @@ describe 'adapting structs into mongo' do
71
72
  data['_id'].should == model.id
72
73
  data['name'].should == 'Test Model'
73
74
  data['other'].should == 'Some Data'
75
+ data['members'].should == 'Some Members'
74
76
  end
75
77
  end
76
78
 
@@ -80,16 +82,17 @@ describe 'adapting structs into mongo' do
80
82
  end
81
83
 
82
84
  describe 'to upsert it' do
83
- subject { adaptor.upsert model, { name: 'My Model' } }
85
+ subject { adaptor.upsert model, { :name => 'My Model' } }
84
86
  it_should_behave_like 'modifying an existing model'
85
87
  end
86
88
 
87
89
  describe 'to fetch it' do
88
90
  subject { adaptor.fetch({ :_id => id }) }
89
- it { should be_a klass }
90
- its(:id) { should == id }
91
- its(:name) { should == 'My Model' }
92
- its(:other) { should == 'Some Value' }
91
+ it { should be_a klass }
92
+ its(:id) { should == id }
93
+ its(:name) { should == 'My Model' }
94
+ its(:other) { should == 'Some Value' }
95
+ its(:members) { should == 'Some Members' }
93
96
  end
94
97
  end
95
98
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_adaptor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-19 00:00:00.000000000 Z
12
+ date: 2012-10-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongo
@@ -122,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  segments:
124
124
  - 0
125
- hash: 3301762641973492072
125
+ hash: -3305026289075587965
126
126
  required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  segments:
133
133
  - 0
134
- hash: 3301762641973492072
134
+ hash: -3305026289075587965
135
135
  requirements: []
136
136
  rubyforge_project:
137
137
  rubygems_version: 1.8.24