Sha256: 2614af4bb1ff6639d4f857cbdc9f86328b26a0b265103ead8794659da5cd972f

Contents?: true

Size: 901 Bytes

Versions: 8

Compression:

Stored size: 901 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 finder DSL methods to delegate
  Methods = Plucky::Query::DSL.instance_methods.sort.map(&:to_sym)

  # Public: Converts value to object id if possible
  #
  # value - The value to attempt converation of
  #
  # Returns BSON::ObjectId or value
  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

  # Private
  ModifierString = '$'

  # Internal
  def self.modifier?(key)
    key.to_s[0, 1] == ModifierString
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
plucky-0.7.0 lib/plucky.rb
plucky-0.6.6 lib/plucky.rb
plucky-0.6.5 lib/plucky.rb
plucky-0.6.4 lib/plucky.rb
plucky-0.6.3 lib/plucky.rb
plucky-0.6.2 lib/plucky.rb
plucky-0.6.1 lib/plucky.rb
plucky-0.6.0 lib/plucky.rb