Class: CedarPolicy::EntityUid

Inherits:
Object
  • Object
show all
Defined in:
lib/cedar_policy/entity_uid.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type_name, id) ⇒ EntityUid

Returns a new instance of EntityUid.



8
9
10
11
12
13
# File 'lib/cedar_policy/entity_uid.rb', line 8

def initialize(type_name, id)
  @type_name = type_name.to_s
  @id = id.to_s

  freeze
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/cedar_policy/entity_uid.rb', line 6

def id
  @id
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



6
7
8
# File 'lib/cedar_policy/entity_uid.rb', line 6

def type_name
  @type_name
end

Instance Method Details

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

Returns:



15
16
17
# File 'lib/cedar_policy/entity_uid.rb', line 15

def eql?(other)
  hash == other.hash
end

#hashObject



20
21
22
# File 'lib/cedar_policy/entity_uid.rb', line 20

def hash
  [self.class, @type_name, @id].hash
end

#to_hashObject



30
31
32
# File 'lib/cedar_policy/entity_uid.rb', line 30

def to_hash
  { type: @type_name, id: @id }
end

#to_strObject Also known as: to_s, inspect



24
25
26
# File 'lib/cedar_policy/entity_uid.rb', line 24

def to_str
  "#{@type_name}::#{@id.inspect}"
end