lib/plucky.rb in plucky-0.4.0 vs lib/plucky.rb in plucky-0.4.1
- old
+ new
@@ -12,19 +12,27 @@
module Pagination
autoload :Decorator, 'plucky/pagination/decorator'
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)
- if value.nil? || (value.respond_to?(:empty?) && value.empty?)
- nil
- elsif value.is_a?(BSON::ObjectId)
- value
+ return value if value.is_a?(BSON::ObjectId)
+ return nil if value.nil? || (value.respond_to?(:empty?) && value.empty?)
+
+ if BSON::ObjectId.legal?(value.to_s)
+ BSON::ObjectId.from_string(value.to_s)
else
- if BSON::ObjectId.legal?(value.to_s)
- BSON::ObjectId.from_string(value.to_s)
- else
- value
- end
+ value
end
end
end