Class: GOM::Object::Id

Inherits:
Object
  • Object
show all
Defined in:
lib/gom/object/id.rb

Overview

Value class for object ids.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id_or_storage_name = nil, object_id = nil) ⇒ Id

Returns a new instance of Id.



8
9
10
11
12
# File 'lib/gom/object/id.rb', line 8

def initialize(id_or_storage_name = nil, object_id = nil)
  @storage_name, @object_id = id_or_storage_name.is_a?(String) ?
    (object_id.is_a?(String) ? [ id_or_storage_name, object_id ] : id_or_storage_name.split(":")) :
    [ nil, nil ]
end

Instance Attribute Details

#object_idObject

Returns the value of attribute object_id.



6
7
8
# File 'lib/gom/object/id.rb', line 6

def object_id
  @object_id
end

#storage_nameObject

Returns the value of attribute storage_name.



5
6
7
# File 'lib/gom/object/id.rb', line 5

def storage_name
  @storage_name
end

Instance Method Details

#==(other) ⇒ Object



14
15
16
# File 'lib/gom/object/id.rb', line 14

def ==(other)
  other.is_a?(self.class) && @storage_name == other.storage_name && @object_id == other.object_id
end

#to_sObject



18
19
20
# File 'lib/gom/object/id.rb', line 18

def to_s
  "#{@storage_name}:#{@object_id}"
end