Module: Mongoid::Extensions::String
- Defined in:
- lib/mongoid/extensions/string.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary (collapse)
-
- (Object) unconvertable_to_bson
Returns the value of attribute unconvertable_to_bson.
- - (Object) unconvertable_to_bson If the document is unconvetable.
Instance Method Summary (collapse)
-
- (String, ...) __evolve_object_id__
Evolve the string into an object id if possible.
-
- (Time) __mongoize_time__
Mongoize the string for storage.
-
- (String) collectionize
Convert the string to a collection friendly name.
-
- (true, false) mongoid_id?
Is the string a valid value for a Mongoid id?.
-
- (true, false) numeric?
Is the string a number?.
-
- (String) reader
Get the string as a getter string.
-
- (Array) to_a
Convert the string to an array with the string in it.
-
- (true, false) unconvertable_to_bson?
Is the object not to be converted to bson on criteria creation?.
-
- (true, false) writer?
Is this string a writer?.
Instance Attribute Details
- (Object) unconvertable_to_bson
Returns the value of attribute unconvertable_to_bson
7 8 9 |
# File 'lib/mongoid/extensions/string.rb', line 7 def unconvertable_to_bson @unconvertable_to_bson end |
- (Object) unconvertable_to_bson If the document is unconvetable.
7 |
# File 'lib/mongoid/extensions/string.rb', line 7 attr_accessor :unconvertable_to_bson |
Instance Method Details
- (String, ...) __evolve_object_id__
Evolve the string into an object id if possible.
17 18 19 20 21 |
# File 'lib/mongoid/extensions/string.rb', line 17 def __evolve_object_id__ unless blank? BSON::ObjectId.legal?(self) ? BSON::ObjectId.from_string(self) : self end end |
- (Time) __mongoize_time__
Mongoize the string for storage.
31 32 33 |
# File 'lib/mongoid/extensions/string.rb', line 31 def __mongoize_time__ ::Time.configured.parse(self) end |
- (String) collectionize
Convert the string to a collection friendly name.
43 44 45 |
# File 'lib/mongoid/extensions/string.rb', line 43 def collectionize tableize.gsub("/", "_") end |
- (true, false) mongoid_id?
Is the string a valid value for a Mongoid id?
55 56 57 |
# File 'lib/mongoid/extensions/string.rb', line 55 def mongoid_id? self =~ /^(|_)id$/ end |
- (true, false) numeric?
Is the string a number?
67 68 69 |
# File 'lib/mongoid/extensions/string.rb', line 67 def numeric? true if Float(self) rescue false end |
- (String) reader
Get the string as a getter string.
79 80 81 |
# File 'lib/mongoid/extensions/string.rb', line 79 def reader delete("=") end |
- (Array) to_a
Convert the string to an array with the string in it.
91 92 93 |
# File 'lib/mongoid/extensions/string.rb', line 91 def to_a [ self ] end |
- (true, false) unconvertable_to_bson?
Is the object not to be converted to bson on criteria creation?
115 116 117 |
# File 'lib/mongoid/extensions/string.rb', line 115 def unconvertable_to_bson? @unconvertable_to_bson ||= false end |
- (true, false) writer?
Is this string a writer?
103 104 105 |
# File 'lib/mongoid/extensions/string.rb', line 103 def writer? include?("=") end |