Class: Clowk::Current

Inherits:
Object
  • Object
show all
Defined in:
lib/clowk/current.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Current

Returns a new instance of Current.



7
8
9
# File 'lib/clowk/current.rb', line 7

def initialize(attributes = {})
  @attributes = attributes.to_h.deep_symbolize_keys
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/clowk/current.rb', line 5

def attributes
  @attributes
end

Instance Method Details

#==(other) ⇒ Object



51
52
53
54
55
# File 'lib/clowk/current.rb', line 51

def ==(other)
  return false unless other.is_a?(Current)

  to_h == other.to_h
end

#[](key) ⇒ Object



43
44
45
# File 'lib/clowk/current.rb', line 43

def [](key)
  attributes[key.to_sym]
end

#app_idObject



35
36
37
# File 'lib/clowk/current.rb', line 35

def app_id
  attributes[:app_id]
end

#avatar_urlObject



23
24
25
# File 'lib/clowk/current.rb', line 23

def avatar_url
  attributes[:avatar_url]
end

#emailObject



15
16
17
# File 'lib/clowk/current.rb', line 15

def email
  attributes[:email]
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/clowk/current.rb', line 57

def eql?(other)
  self == other
end

#hashObject



61
62
63
# File 'lib/clowk/current.rb', line 61

def hash
  to_h.hash
end

#idObject



11
12
13
# File 'lib/clowk/current.rb', line 11

def id
  attributes[:sub] || attributes[:id]
end

#instance_idObject



31
32
33
# File 'lib/clowk/current.rb', line 31

def instance_id
  attributes[:instance_id]
end

#nameObject



19
20
21
# File 'lib/clowk/current.rb', line 19

def name
  attributes[:name]
end

#providerObject



27
28
29
# File 'lib/clowk/current.rb', line 27

def provider
  attributes[:provider]
end

#session_idObject



39
40
41
# File 'lib/clowk/current.rb', line 39

def session_id
  attributes[:session_id]
end

#to_hObject



47
48
49
# File 'lib/clowk/current.rb', line 47

def to_h
  attributes.merge(id: id)
end