Module: ActsAsDashboard::ClassMethods
- Defined in:
- lib/acts_as_dashboard/class_methods.rb
Instance Attribute Summary collapse
-
#dashboard_config ⇒ Object
readonly
Returns the value of attribute dashboard_config.
Instance Method Summary collapse
- #acts_as_dashboard ⇒ Object
- #dashboard_line_graph(&block) ⇒ Object
- #dashboard_number(&block) ⇒ Object
- #dashboard_short_messages(&block) ⇒ Object
Instance Attribute Details
#dashboard_config ⇒ Object (readonly)
Returns the value of attribute dashboard_config.
3 4 5 |
# File 'lib/acts_as_dashboard/class_methods.rb', line 3 def dashboard_config @dashboard_config end |
Instance Method Details
#acts_as_dashboard ⇒ Object
5 6 7 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 |
# File 'lib/acts_as_dashboard/class_methods.rb', line 5 def acts_as_dashboard @dashboard_config = ActsAsDashboard::Config.new include InstanceMethods controller_name = self.to_s.underscore.sub('_controller', '').singularize # # This is commented out because having it here doesn't actually work. I believe this # # is because calls to #acts_as_dashboard within controllers aren't invoked until one # # of the controller's actions is called. However, it's impossible to call one of the # # actions of an acts_as_dashboard-enabled controller because there aren't any routes # # yet! It's a catch-22. Argh. # # # Create the route for the "show" action. This will be something like: # # /dashboard # ActionController::Routing::Routes.add_named_route( # 'dashboard', # controller_name, # :controller => controller_name.pluralize.to_sym, # :action => :show # ) # # # Create the route for the "widget_data" action. This will be something like: # # /dashboard/widgets/* # ActionController::Routing::Routes.add_named_route( # "#{controller_name}_widgets", # "#{controller_name}/widgets/*path", # :controller => controller_name.pluralize.to_sym, # :action => :widget_data # ) end |
#dashboard_line_graph(&block) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/acts_as_dashboard/class_methods.rb', line 55 def dashboard_line_graph(&block) raise ArgumentError, 'A Proc must be given.' unless block_given? = LineGraphWidget.new .instance_eval &block dashboard_config. end |
#dashboard_number(&block) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/acts_as_dashboard/class_methods.rb', line 37 def dashboard_number(&block) raise ArgumentError, 'A Proc must be given.' unless block_given? = Widget.new :type => :number .instance_eval &block dashboard_config. end |
#dashboard_short_messages(&block) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/acts_as_dashboard/class_methods.rb', line 46 def (&block) raise ArgumentError, 'A Proc must be given.' unless block_given? = ShortMessagesWidget.new .instance_eval &block dashboard_config. end |