Class: ConcertoContentScheduling::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/concerto_content_scheduling/engine.rb

Instance Method Summary collapse

Instance Method Details

#plugin_info(plugin_info_class) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/concerto_content_scheduling/engine.rb', line 8

def plugin_info(plugin_info_class)
  @plugin_info ||= plugin_info_class.new do

    extend_model Content, ConcertoContentScheduling::Concerns::Scheduling
    
    add_view_hook "ContentsController", 
                  :content_form, 
                  :partial => "concerto_content_scheduling/content/schedule"

    add_view_hook "ContentsController", 
                  :content_details, 
                  :partial => "concerto_content_scheduling/content/details"

    add_view_hook "ContentsController", 
                  :tile_labels, 
                  :partial => "concerto_content_scheduling/content/tile_labels"

    # filter the contents according to the schedule
    # the manykinds plugin if concurrently enabled will cause this to be skipped
    add_controller_hook "Subscription", :filter_contents, :after do
      @contents.reject!{|c| !c.is_active_per_schedule?}
    end

    add_controller_hook "ContentsController", :update_params, :after do
      @attributes.concat([:schedule_info => [:criteria, :start_time, :end_time]])
    end

    # make sure dynamic content has the same schedule as it's parent item
    add_controller_hook "DynamicContent", :alter_content, :after do
      @new_attributes[:schedule_info] = @content.parent.schedule_info
    end        

  end
end