Module: Plucky

Defined in:
lib/plucky.rb,
lib/plucky/query.rb,
lib/plucky/version.rb,
lib/plucky/options_hash.rb,
lib/plucky/criteria_hash.rb,
lib/plucky/extensions/symbol.rb,
lib/plucky/pagination/decorator.rb,
lib/plucky/pagination/paginator.rb

Defined Under Namespace

Modules: Extensions, Pagination Classes: CriteriaHash, OptionsHash, Query

Constant Summary collapse

Version =
'0.3.8'
MongoVersion =
'~> 1.3'

Class Method Summary collapse

Class Method Details

.to_object_id(value) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/plucky.rb', line 17

def self.to_object_id(value)
  if value.nil? || (value.respond_to?(:empty?) && value.empty?)
    nil
  elsif value.is_a?(BSON::ObjectId)
    value
  else
    if BSON::ObjectId.legal?(value.to_s)
      BSON::ObjectId.from_string(value.to_s)
    else
      value
    end
  end
end