Class: RedBase::Dashboard

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/red_base/dashboard.rb,
lib/red_base/dashboard/module.rb,
lib/red_base/dashboard/controller.rb

Overview

This Module is the base module for dashboard

Defined Under Namespace

Modules: Controller, Module

Constant Summary collapse

@@modules =
{}
@@sections =
{}

Instance Method Summary collapse

Instance Method Details

#content_for(section) ⇒ Object

Return content for given section by calling related method in each registered module which registered to specified section



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/red_base/dashboard.rb', line 44

def content_for(section)

  result = []
  if @@sections.include? section
    @@sections[section].each do |module_name|
      # Get module object form @@modules
      result << [@@modules[module_name].priority,
                 @@modules[modue_name].send("content_for_#{section}")]
    end
  end
  result.sort.reverse.join("\n").html_safe
end

#register_module(section, dashboard_module) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/red_base/dashboard.rb', line 29

def register_module(section, dashboard_module)

  if not @@modules.include? dashboard_module.name
    @@modules[dashboard_module.name.to_sym] = dashboard_module

    if not @@sections.include? section.to_sym
      @@sections[section.to_sym] = []
    end
    @@sections[section.to_sym] << dashboard_module.name
  end
end