populate-me 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,7 +38,9 @@ module PopulateMe
38
38
  def find(selector={},opts={})
39
39
  selector.update(opts.delete(:selector)||{})
40
40
  opts = {:sort=>self.sorting_order}.update(opts)
41
- collection.find(selector,opts).extend(CursorMutation)
41
+ cur = collection.find(selector,opts)
42
+ cur.instance_variable_set('@mutant_class', self)
43
+ cur.extend(CursorMutation)
42
44
  end
43
45
  def find_one(spec_or_object_id=nil,opts={})
44
46
  spec_or_object_id.nil? ? spec_or_object_id = opts.delete(:selector) : spec_or_object_id.update(opts.delete(:selector)||{})
@@ -272,12 +274,7 @@ module PopulateMe
272
274
  # We must keep the regular cursor
273
275
  # so we should extend on demand.
274
276
  # Meaning the cursor object should be extended, not the cursor class.
275
- def self.extended(into)
276
- into.set_mutant_class
277
- end
278
- def set_mutant_class
279
- @mutant_class = Kernel.const_get(collection.name)
280
- end
277
+ # @mutant_class should be defined before extending
281
278
  def next
282
279
  n = super
283
280
  n.nil? ? nil : @mutant_class.new(n)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'populate-me'
3
- s.version = "0.0.19"
3
+ s.version = "0.0.20"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.summary = "ALPHA !!! Populate Me is relatively complete but simple CMS"
6
6
  s.description = "ALPHA !!! Populate Me is relatively complete but simple CMS. It includes a Rack middleware for putting in your Rack stack, and a bespoke MongoDB ODM. But Populate Me is not really finished yet."
@@ -260,6 +260,10 @@ describe "PopulateMe::Mongo::Mutation" do
260
260
  # #save
261
261
 
262
262
  describe 'CursorMutation' do
263
+ it 'Should give the correct class of object on iterations' do
264
+ Address.new('body'=>'42').save
265
+ Address.find.to_a[0].model.name.should=='Address'
266
+ end
263
267
  end
264
268
 
265
269
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: populate-me
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
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: 2013-12-24 00:00:00.000000000 Z
12
+ date: 2014-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack-golem
@@ -122,4 +122,3 @@ signing_key:
122
122
  specification_version: 3
123
123
  summary: ALPHA !!! Populate Me is relatively complete but simple CMS
124
124
  test_files: []
125
- has_rdoc: