Class: Clever::Types::Event

Inherits:
Base
  • Object
show all
Defined in:
lib/clever/types/event.rb

Constant Summary collapse

TYPE_MAP =
{
  'sections' => ::Clever::Types::Section,
  'teachers' => ::Clever::Types::Teacher,
  'students' => ::Clever::Types::Student
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#blank?, #presence, #to_h

Constructor Details

#initialize(attributes = {}) ⇒ Event

Returns a new instance of Event.



22
23
24
25
26
27
# File 'lib/clever/types/event.rb', line 22

def initialize(attributes = {}, *)
  @uid           = attributes['id']
  @type, @action = attributes['type'].split('.')
  @object        = TYPE_MAP[@type]&.new(attributes['data']['object'])
  @provider      = 'clever'
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



10
11
12
# File 'lib/clever/types/event.rb', line 10

def action
  @action
end

#objectObject (readonly)

Returns the value of attribute object.



10
11
12
# File 'lib/clever/types/event.rb', line 10

def object
  @object
end

#providerObject (readonly)

Returns the value of attribute provider.



10
11
12
# File 'lib/clever/types/event.rb', line 10

def provider
  @provider
end

#typeObject (readonly)

Returns the value of attribute type.



10
11
12
# File 'lib/clever/types/event.rb', line 10

def type
  @type
end

#uidObject (readonly)

Returns the value of attribute uid.



10
11
12
# File 'lib/clever/types/event.rb', line 10

def uid
  @uid
end