Skip to content

Commit

Permalink
Fixed the readme so people can use with the newest DM 0.9.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
myobie committed Jun 9, 2008
1 parent dda1802 commit c4c5829
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
12 changes: 10 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,17 @@ platform, let me know.
Usage
=====

Using this plugin is like so in init.rb:
Using this plugin is like so in your model:

dependency 'merb_paginate'
class Post
include DataMapper::Resource
include MerbPaginate::Finders::Datamapper

property ...
...
end

**You also must have 'dm-aggregates' as a dependency in you init.rb.**

Right now, DataMapper and ActiveRecord work (Sequel might work, let me know).
I hope to have a fully speced paginate finder for each orm evenutally.
Expand Down
8 changes: 6 additions & 2 deletions example/app/models/post.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
class Post < DataMapper::Base
property :title, :string
class Post
include DataMapper::Resource
include MerbPaginate::Finders::Datamapper

property :id, Integer, :serial => true
property :title, String
end
2 changes: 1 addition & 1 deletion example/config/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
use_orm :datamapper
use_test :rspec

dependencies 'merb-haml', 'merb_paginate'
dependencies 'merb-haml', 'dm-aggregates', 'merb_paginate'
11 changes: 3 additions & 8 deletions lib/merb_paginate/finders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
if Object.const_defined? "DataMapper"
require 'merb_paginate/finders/datamapper'
# better than using Gem.loaded_specs as RubyGems is not required
target = DataMapper.const_defined?('Base') ? 'Base' : 'Resource'
DataMapper::const_get(target).class_eval { include MerbPaginate::Finders::Datamapper }

DataMapper::Resource.descendents.each { |resource|
# Take care of DataMapper::Resource descendents (sic)
# that have already been declared
resource.class_eval { include MerbPaginate::Finders::Datamapper }
} if target == 'Resource'
if DataMapper.const_defined?('Base')
DataMapper::Base.class_eval { include MerbPaginate::Finders::Datamapper }
end
end

if Object.const_defined? "Sequel"
Expand Down

0 comments on commit c4c5829

Please sign in to comment.