Class: Course::Video::Session

Inherits:
ApplicationRecord show all
Defined in:
app/models/course/video/session.rb

Instance Method Summary collapse

Instance Method Details

#merge_in_events!(events_attributes) ⇒ Object

Inserts (or updates if the sequence number collides) events into this session.

Parameters:

  • events_attributes ([Hash])

    A list of hashes specifying the attributes for events.

  • events_attributes (Hash)

    A hash specifying the attributes for a event.


18
19
20
21
22
23
24
# File 'app/models/course/video/session.rb', line 18

def merge_in_events!(events_attributes)
  params_list = events_attributes.respond_to?(:each) ? events_attributes : [events_attributes]

  params_list.each do |event_params|
    events.build(event_params).upsert!
  end
end