lib/plucky.rb in plucky-0.5.2 vs lib/plucky.rb in plucky-0.6.0
- old
+ new
@@ -11,16 +11,29 @@
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