Class: Lutaml::Store::StorageKey

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/store/storage_key.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class_name, key_value) ⇒ StorageKey

Returns a new instance of StorageKey.



8
9
10
11
# File 'lib/lutaml/store/storage_key.rb', line 8

def initialize(class_name, key_value)
  @class_name = class_name.to_s
  @key_value = key_value.to_s
end

Instance Attribute Details

#class_nameObject (readonly)

Returns the value of attribute class_name.



6
7
8
# File 'lib/lutaml/store/storage_key.rb', line 6

def class_name
  @class_name
end

#key_valueObject (readonly)

Returns the value of attribute key_value.



6
7
8
# File 'lib/lutaml/store/storage_key.rb', line 6

def key_value
  @key_value
end

Class Method Details

.parse(string) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/lutaml/store/storage_key.rb', line 19

def self.parse(string)
  str = string.to_s
  sep = str.rindex(/(?<!:):(?!:)/)
  return new("", str) unless sep

  new(str[0...sep], str[sep + 1..])
end

Instance Method Details

#==(other) ⇒ Object



35
36
37
# File 'lib/lutaml/store/storage_key.rb', line 35

def ==(other)
  to_s == other.to_s
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/lutaml/store/storage_key.rb', line 27

def eql?(other)
  other.is_a?(StorageKey) && to_s == other.to_s
end

#hashObject



31
32
33
# File 'lib/lutaml/store/storage_key.rb', line 31

def hash
  to_s.hash
end

#to_sObject Also known as: to_str



13
14
15
# File 'lib/lutaml/store/storage_key.rb', line 13

def to_s
  "#{@class_name}:#{@key_value}"
end