Class: Ettin::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/ettin/key.rb

Overview

Internal hash key that handles strings and symbols as the same type.

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Key

Returns a new instance of Key.



8
9
10
# File 'lib/ettin/key.rb', line 8

def initialize(key)
  @key = key
end

Instance Method Details

#classObject



16
17
18
# File 'lib/ettin/key.rb', line 16

def class
  Symbol
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


28
29
30
# File 'lib/ettin/key.rb', line 28

def eql?(other)
  to_sym == other.to_s.to_sym
end

#hashObject



33
34
35
# File 'lib/ettin/key.rb', line 33

def hash
  key.to_s.to_sym.hash
end

#inspectObject



12
13
14
# File 'lib/ettin/key.rb', line 12

def inspect
  to_sym.inspect
end

#to_sObject



20
21
22
# File 'lib/ettin/key.rb', line 20

def to_s
  key.to_s
end

#to_symObject



24
25
26
# File 'lib/ettin/key.rb', line 24

def to_sym
  to_s.to_sym
end