Class: RubyUIAdmin::BaseDashboard
- Inherits:
-
Object
- Object
- RubyUIAdmin::BaseDashboard
- Defined in:
- lib/ruby_ui_admin/base_dashboard.rb
Overview
Base class for dashboards. Host dashboards (RubyUIAdmin::Dashboards::*) inherit
this and declare cards in def cards.
Class Method Summary collapse
- .abstract? ⇒ Boolean
- .description ⇒ Object
- .description=(value) ⇒ Object
- .grid_columns ⇒ Object
- .grid_columns=(value) ⇒ Object
- .id ⇒ Object
- .id=(value) ⇒ Object
- .name ⇒ Object
-
.name=(value) ⇒ Object
Class-level
self.name =with fallback to the real class name. -
.title ⇒ Object
Display title (falls back to a humanized class name).
Instance Method Summary collapse
- #card(klass, **options) ⇒ Object
- #card_items ⇒ Object
-
#cards ⇒ Object
Overridden by subclasses to declare cards.
- #divider ⇒ Object
- #get_cards ⇒ Object
Class Method Details
.abstract? ⇒ Boolean
46 47 48 |
# File 'lib/ruby_ui_admin/base_dashboard.rb', line 46 def abstract? self == RubyUIAdmin::BaseDashboard end |
.description ⇒ Object
29 30 31 |
# File 'lib/ruby_ui_admin/base_dashboard.rb', line 29 def description defined?(@description) ? @description : nil end |
.description=(value) ⇒ Object
25 26 27 |
# File 'lib/ruby_ui_admin/base_dashboard.rb', line 25 def description=(value) @description = value end |
.grid_columns ⇒ Object
37 38 39 |
# File 'lib/ruby_ui_admin/base_dashboard.rb', line 37 def grid_columns (defined?(@grid_columns) && @grid_columns) || 3 end |
.grid_columns=(value) ⇒ Object
33 34 35 |
# File 'lib/ruby_ui_admin/base_dashboard.rb', line 33 def grid_columns=(value) @grid_columns = value end |
.id ⇒ Object
21 22 23 |
# File 'lib/ruby_ui_admin/base_dashboard.rb', line 21 def id (defined?(@id) && @id) || to_s.demodulize.underscore end |
.id=(value) ⇒ Object
17 18 19 |
# File 'lib/ruby_ui_admin/base_dashboard.rb', line 17 def id=(value) @id = value end |
.name ⇒ Object
13 14 15 |
# File 'lib/ruby_ui_admin/base_dashboard.rb', line 13 def name @display_name || super end |
.name=(value) ⇒ Object
Class-level self.name = with fallback to the real class name.
9 10 11 |
# File 'lib/ruby_ui_admin/base_dashboard.rb', line 9 def name=(value) @display_name = value end |
.title ⇒ Object
Display title (falls back to a humanized class name).
42 43 44 |
# File 'lib/ruby_ui_admin/base_dashboard.rb', line 42 def title @display_name || to_s.demodulize.titleize end |
Instance Method Details
#card(klass, **options) ⇒ Object
54 55 56 |
# File 'lib/ruby_ui_admin/base_dashboard.rb', line 54 def card(klass, **) card_items << {klass: klass, options: } end |
#card_items ⇒ Object
60 61 62 |
# File 'lib/ruby_ui_admin/base_dashboard.rb', line 60 def card_items @card_items ||= [] end |
#cards ⇒ Object
Overridden by subclasses to declare cards.
52 |
# File 'lib/ruby_ui_admin/base_dashboard.rb', line 52 def cards; end |
#divider ⇒ Object
58 |
# File 'lib/ruby_ui_admin/base_dashboard.rb', line 58 def divider(**); end |
#get_cards ⇒ Object
64 65 66 67 68 |
# File 'lib/ruby_ui_admin/base_dashboard.rb', line 64 def get_cards @card_items = [] cards card_items.map { |entry| entry[:klass].new(**(entry[:options] || {})) } end |