Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a bug and added a spec.

  • Loading branch information...
commit d593637f964f8dac8c357be470335f3ba2531622 1 parent 59debf6
@genki authored
View
2  Rakefile
@@ -5,7 +5,7 @@ require 'merb-core'
require 'merb-core/tasks/merb'
GEM_NAME = "dm-pagination"
-GEM_VERSION = "0.1.1"
+GEM_VERSION = "0.1.2"
AUTHOR = "Genki Takiuchi"
EMAIL = "genki@s21g.com"
HOMEPAGE = "http://blog.s21g.com/genki"
View
2  dm-pagination.gemspec
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.name = %q{dm-pagination}
- s.version = "0.1.1"
+ s.version = "0.1.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Genki Takiuchi"]
View
4 lib/dm-pagination/pagination.rb
@@ -29,6 +29,10 @@ def count
[0, [@proxy_collection.count - offset, @per_page].min].max
end
+ def respond_to?(*args, &block)
+ super || @collection.send(:respond_to?, *args, &block)
@dkubb
dkubb added a note

FYI Collection#respond_to? is a public method, so there’s no real need to use Collection#send() to access it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ end
+
def method_missing(method, *args, &block)
@collection.send(method, *args, &block)
end
View
4 spec/dm-pagination_spec.rb
@@ -17,6 +17,10 @@
Post.paginate.should be_kind_of(DmPagination::Pagination)
Post.all.paginate.should be_kind_of(DmPagination::Pagination)
end
+
+ it "should respond to model's method" do
+ Post.paginate.should be_respond_to(:to_atom)
+ end
end
describe "pagination" do
View
4 spec/fixture/app/models/post.rb
@@ -3,4 +3,8 @@ class Post
property :id, Serial
property :index, Integer
+
+ def self.to_atom
+ "atom"
+ end
end
@dkubb

FYI Collection#respond_to? is a public method, so there’s no real need to use Collection#send() to access it.

Please sign in to comment.
Something went wrong with that request. Please try again.