Sha256: c3b4e287a0f1f2379b0b75105c595a8ee7a1c2a85fdf474ae3d1d5c3889f23fc

Contents?: true

Size: 1011 Bytes

Versions: 23

Compression:

Stored size: 1011 Bytes

Contents

# #
# AUTO GENERATED LIVE EVENT
# This was auto generated by the CanvasSync Gem.
# You can customize it as needed, but make sure you test
# any changes you make to the auto generated methods.
#


module LiveEvents
  class UserEvent < LiveEvents::BaseEvent
    # The following is provided in the live events call:
    # {
    #   user_id: user.global_id,
    #   uuid: user.uuid,
    #   name: user.name,
    #   short_name: user.short_name,
    #   workflow_state: user.workflow_state,
    #   created_at: user.created_at,
    #   updated_at: user.updated_at
    # }

    def perform(event_payload)
      super
      attrs = {
        canvas_user_id: local_canvas_id(payload[:user_id]),
        full_name: payload[:name],
        status: payload[:workflow_state],
      }
      create_or_update(attrs)
    end

    private

    def create_or_update(attrs)
      user = User.where(canvas_user_id: attrs[:canvas_user_id]).first_or_initialize
      user.assign_attributes(attrs)
      user.save!
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
canvas_sync-0.9.4 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.9.3 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.9.2 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.9.1 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.9.0 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.8.4 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.8.3 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.8.2 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.8.1 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.8.0 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.7.3 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.7.2 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.7.1 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.7.0 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.6.4 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.6.3 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.6.2 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.6.1 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.6.0 spec/dummy/app/services/live_events/user_event.rb
canvas_sync-0.5.4 spec/dummy/app/services/live_events/user_event.rb