Class: MarkLogic::ObjectId
- Inherits:
-
Object
- Object
- MarkLogic::ObjectId
- Defined in:
- lib/marklogic/object_id.rb
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #as_json(options = nil) ⇒ Object
- #hash ⇒ Object
-
#initialize ⇒ ObjectId
constructor
A new instance of ObjectId.
- #inspect ⇒ Object
- #to_json(options = nil) ⇒ Object
- #to_s ⇒ Object (also: #to_str)
Constructor Details
#initialize ⇒ ObjectId
Returns a new instance of ObjectId.
8 9 10 |
# File 'lib/marklogic/object_id.rb', line 8 def initialize @id = SecureRandom.hex end |
Class Method Details
.from_string(str) ⇒ Object
21 22 23 24 25 |
# File 'lib/marklogic/object_id.rb', line 21 def from_string(str) object_id = allocate object_id.instance_variable_set(:@id, str) object_id end |
.legal?(string) ⇒ Boolean
27 28 29 |
# File 'lib/marklogic/object_id.rb', line 27 def legal?(string) string.to_s =~ /^[0-9a-f]{32}$/i ? true : false end |
Instance Method Details
#==(other) ⇒ Object
32 33 34 |
# File 'lib/marklogic/object_id.rb', line 32 def ==(other) to_s == other.to_s end |
#as_json(options = nil) ⇒ Object
36 37 38 |
# File 'lib/marklogic/object_id.rb', line 36 def as_json(=nil) to_s end |
#hash ⇒ Object
44 45 46 |
# File 'lib/marklogic/object_id.rb', line 44 def hash to_s.hash end |
#inspect ⇒ Object
16 17 18 |
# File 'lib/marklogic/object_id.rb', line 16 def inspect "#<#{self.class}('#{@id}')>" end |
#to_json(options = nil) ⇒ Object
40 41 42 |
# File 'lib/marklogic/object_id.rb', line 40 def to_json( = nil) as_json.to_json end |
#to_s ⇒ Object Also known as: to_str
12 13 14 |
# File 'lib/marklogic/object_id.rb', line 12 def to_s @id end |