mongomapper_ext 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -39,8 +39,8 @@ module MongoMapperExt
39
39
  end
40
40
 
41
41
  module Finder
42
- def by_slug(id)
43
- self.find_by_slug(id) || self.find_by_id(id)
42
+ def by_slug(id, options = {})
43
+ self.find_by_slug(id, options) || self.find_by_id(id, options)
44
44
  end
45
45
  alias :find_by_slug_or_id :by_slug
46
46
  end
@@ -31,7 +31,14 @@ module MongoMapperExt
31
31
  end
32
32
 
33
33
  def files
34
- criteria, options = MongoMapper::FinderOptions.new(self.class, :metadata => {:_id => self.id}).to_a
34
+ finder = nil
35
+ if defined?(MongoMapper::FinderOptions)
36
+ finder = MongoMapper::FinderOptions
37
+ else
38
+ finder = MongoMapper::Query
39
+ end
40
+
41
+ criteria, options = finder.new(self.class, :metadata => {:_id => self.id}).to_a
35
42
  coll = self.class.database.collection("#{self.collection.name}.files")
36
43
  @files = coll.find(criteria, options).map do |a|
37
44
  MongoMapperExt::File.new(self, a)
@@ -66,7 +73,8 @@ module MongoMapperExt
66
73
  end
67
74
 
68
75
  define_method(name) do
69
- fetch_file(self["_#{name}"]) if metaclass.keys.has_key?("_#{name}")
76
+ puts "NAME: #{name}"
77
+ fetch_file(self["_#{name}"]) if self.class.keys.has_key?("_#{name}")
70
78
  end
71
79
 
72
80
  define_method("has_#{name}?") do
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongomapper_ext}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David A. Cuadrado"]
12
- s.date = %q{2010-02-11}
12
+ s.date = %q{2010-02-21}
13
13
  s.description = %q{MongoMapper extensions}
14
14
  s.email = %q{krawek@gmail.com}
15
15
  s.extra_rdoc_files = [
data/test/test_filter.rb CHANGED
@@ -6,8 +6,7 @@ class TestFilter < Test::Unit::TestCase
6
6
  BlogPost.delete_all
7
7
  @blogpost = BlogPost.create(:title => "%How dOEs tHIs Work?!",
8
8
  :body => "HeRe is tHe Body of the bLog pOsT",
9
- :tags => ["my", "list", "of", "tags"],
10
- :date => Time.parse('01-01-2009'))
9
+ :tags => ["my", "list", "of", "tags"])
11
10
  end
12
11
 
13
12
  should "be case insensitive" do
@@ -13,7 +13,7 @@ class TimestampTest < Test::Unit::TestCase
13
13
  @start_time = Time.zone.parse('01-01-2009')
14
14
  @end_time = @start_time.tomorrow
15
15
 
16
- @event = Event.create!(:start_date => @start_time, :end_date => @end_time)
16
+ @event = Event.create!(:start_date => @start_time.to_i, :end_date => @end_time.to_i)
17
17
  end
18
18
 
19
19
  should "store the date" do
@@ -29,7 +29,7 @@ class TimestampTest < Test::Unit::TestCase
29
29
  start_time = @start_time.tomorrow.tomorrow
30
30
  end_time = start_time.tomorrow
31
31
 
32
- @event2 = Event.create!(:start_date => start_time, :end_datime => end_time)
32
+ @event2 = Event.create!(:start_date => start_time.utc, :end_datime => end_time.utc)
33
33
 
34
34
  Event.count.should == 2
35
35
  events = Event.find(:all, :$where => ("this.start_date >= %d && this.start_date <= %d" % [@event.start_date.yesterday.to_i, @event2.start_date.yesterday.to_i]))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongomapper_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David A. Cuadrado
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-11 00:00:00 -05:00
12
+ date: 2010-02-21 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency