Skip to content

Commit

Permalink
Added array of methods that perform queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed May 28, 2011
1 parent 966abc9 commit e199b33
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/plucky.rb
Expand Up @@ -14,6 +14,17 @@ module Pagination
autoload :Paginator, 'plucky/pagination/paginator'
end

# Array of methods that actually perform queries
Methods = [
:where, :filter, :limit, :skip, :offset, :sort, :order,
:fields, :ignore, :only,
:each, :find_each,
:count, :size, :distinct,
:last, :first, :all, :paginate,
:exists?, :exist?, :empty?,
:to_a, :remove,
]

def self.to_object_id(value)
return value if value.is_a?(BSON::ObjectId)
return nil if value.nil? || (value.respond_to?(:empty?) && value.empty?)
Expand Down
14 changes: 14 additions & 0 deletions test/test_plucky.rb
Expand Up @@ -28,5 +28,19 @@ class PluckyTest < Test::Unit::TestCase
Plucky.to_object_id(1).should == 1
end
end

context "::Methods" do
should "return array of methods" do
Plucky::Methods.should == [
:where, :filter, :limit, :skip, :offset, :sort, :order,
:fields, :ignore, :only,
:each, :find_each,
:count, :size, :distinct,
:last, :first, :all, :paginate,
:exists?, :exist?, :empty?,
:to_a, :remove,
]
end
end
end
end

0 comments on commit e199b33

Please sign in to comment.