Sha256: 5cab84134a2013162ac8a32b48e3588438ba34aaf02b9775c70906bf283824f7

Contents?: true

Size: 826 Bytes

Versions: 3

Compression:

Stored size: 826 Bytes

Contents

# encoding: UTF-8
require 'set'
require 'mongo'
require 'plucky/extensions'
require 'plucky/criteria_hash'
require 'plucky/options_hash'
require 'plucky/query'
require 'plucky/pagination'

module Plucky
  autoload :Version, 'plucky/version'

  # 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?)

    if BSON::ObjectId.legal?(value.to_s)
      BSON::ObjectId.from_string(value.to_s)
    else
      value
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
plucky-0.4.4 lib/plucky.rb
plucky-0.4.3 lib/plucky.rb
plucky-0.4.2 lib/plucky.rb