Skip to content

Commit

Permalink
Add ruby 1.8.7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Rozumey committed Nov 16, 2011
1 parent bde6d26 commit 7428dcf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions .travis.yml
@@ -1,3 +1,4 @@
rvm:
- 1.8.6
- 1.9.2
- 1.9.3
2 changes: 1 addition & 1 deletion lib/mongoid/mapreduce/reducer.rb
Expand Up @@ -65,7 +65,7 @@ def field(sym, options={})
# containing Mongoid::MapReduce::Document objects (hashes)
def run
begin
coll = @klass.collection.map_reduce(formula.map, formula.reduce, { query: @selector, out: "#map_reduce" } ).find.to_a
coll = @klass.collection.map_reduce(formula.map, formula.reduce, { :query => @selector, :out => "#map_reduce" } ).find.to_a
rescue
raise "Error: could not execute map reduce function"
end
Expand Down
8 changes: 4 additions & 4 deletions spec/models/company.rb
Expand Up @@ -2,10 +2,10 @@ class Company
include Mongoid::Document
include Mongoid::MapReduce

field :name, type: String
field :market, type: String
field :shares, type: Integer
field :quote, type: Float
field :name, :type => String
field :market, :type => String
field :shares, :type => Integer
field :quote, :type => Float

has_many :employees
end
10 changes: 5 additions & 5 deletions spec/mongoid/mapreduce_spec.rb
Expand Up @@ -50,24 +50,24 @@

it 'can be integers' do
r = Employee.map_reduce do
field :age, type: Integer
field :age, :type => Integer
end
r.first.age.should be_an_instance_of(Fixnum)
end

it 'can be floats' do
r = Company.map_reduce(:market) do
field :quote, type: Float
field :shares, type: Integer
field :quote, :type => Float
field :shares, :type => Integer
end
r.first.quote.should be_an_instance_of(Float)
r.find('Technology').quote.should eql (@aapl.quote + @msft.quote)
r.find('Technology').quote.should eql(@aapl.quote + @msft.quote)
r.find('Food').quote.should eql @sbux.quote
end

it 'can be strings' do
r = Employee.map_reduce(:division) do
field :age, type: String
field :age, :type => String
end
r.first.age.should be_an_instance_of(String)
r.find('Hardware').age.should eql "30"
Expand Down

0 comments on commit 7428dcf

Please sign in to comment.