Class: Course::Video::Tab

Inherits:
ApplicationRecord show all
Includes:
ModelComponentHost::Component
Defined in:
app/models/course/video/tab.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.after_course_initialize(course) ⇒ Object


12
13
14
15
16
17
# File 'app/models/course/video/tab.rb', line 12

def self.after_course_initialize(course)
  return if course.persisted? || !course.video_tabs.empty?

  course.video_tabs.
    build(title: human_attribute_name('title.default'), weight: 0)
end

Instance Method Details

#initialize_duplicate(duplicator, other) ⇒ Object


27
28
29
30
31
32
# File 'app/models/course/video/tab.rb', line 27

def initialize_duplicate(duplicator, other)
  self.course = duplicator.options[:destination_course]
  other.videos.each do |video|
    videos << duplicator.duplicate(video) if duplicator.duplicated?(video)
  end
end

#other_tabs_remaining?Boolean

Returns a boolean value indicating if there are other video tabs besides this one remaining in the course.


23
24
25
# File 'app/models/course/video/tab.rb', line 23

def other_tabs_remaining?
  course.video_tabs.count > 1
end