Class: OMF::Web::Widget::AbstractWidget
- Inherits:
-
Erector::Widget
- Object
- Erector::Widget
- OMF::Web::Widget::AbstractWidget
- Extended by:
- Base::Loggable
- Includes:
- Base::Loggable
- Defined in:
- lib/omf-web/widget/abstract_widget.rb
Overview
Maintains the context for a particular code rendering within a specific session.
Direct Known Subclasses
Code::CodeWidget, CodeWidget, DataWidget, Layout::FlowLayout, Layout::OneColumnLayout, Layout::StackedLayout, Layout::TabbedLayout, Layout::TwoColumnsLayout, MustacheWidget, TextWidget
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#widget_id ⇒ Object
readonly
Returns the value of attribute widget_id.
-
#widget_type ⇒ Object
readonly
Returns the value of attribute widget_type.
Instance Method Summary collapse
- #collect_data_sources(ds_set) ⇒ Object
-
#initialize(opts = {}) ⇒ AbstractWidget
constructor
A new instance of AbstractWidget.
- #layout? ⇒ Boolean
- #mime_type ⇒ Object
- #title ⇒ Object
-
#tools_menu ⇒ Object
Return html for an optional widget tools menu to be added to the widget decoration by the theme.
-
#widget_info ⇒ Object
Return text to provide information about this widget.
Constructor Details
#initialize(opts = {}) ⇒ AbstractWidget
Returns a new instance of AbstractWidget.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/omf-web/widget/abstract_widget.rb', line 15 def initialize(opts = {}) super @opts = opts @widget_id = opts[:id] unless @name = opts[:name] @name = opts[:id] #? opts[:id].to_s.capitalize : 'Unknown: Set opts[:name]' end unless @widget_type = opts[:type] raise "Missing 'type' in '#{opts.inspect}'" end OMF::Web::SessionStore[@widget_id, :w] = self end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/omf-web/widget/abstract_widget.rb', line 13 def name @name end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
13 14 15 |
# File 'lib/omf-web/widget/abstract_widget.rb', line 13 def opts @opts end |
#widget_id ⇒ Object (readonly)
Returns the value of attribute widget_id.
13 14 15 |
# File 'lib/omf-web/widget/abstract_widget.rb', line 13 def @widget_id end |
#widget_type ⇒ Object (readonly)
Returns the value of attribute widget_type.
13 14 15 |
# File 'lib/omf-web/widget/abstract_widget.rb', line 13 def @widget_type end |
Instance Method Details
#collect_data_sources(ds_set) ⇒ Object
54 55 56 |
# File 'lib/omf-web/widget/abstract_widget.rb', line 54 def collect_data_sources(ds_set) raise "Should have been implemented" end |
#layout? ⇒ Boolean
42 43 44 |
# File 'lib/omf-web/widget/abstract_widget.rb', line 42 def layout? return false end |
#mime_type ⇒ Object
50 51 52 |
# File 'lib/omf-web/widget/abstract_widget.rb', line 50 def mime_type @opts[:mime_type] || 'unknown' end |
#title ⇒ Object
46 47 48 |
# File 'lib/omf-web/widget/abstract_widget.rb', line 46 def title @opts[:title] end |
#tools_menu ⇒ Object
Return html for an optional widget tools menu to be added to the widget decoration by the theme.
38 39 40 |
# File 'lib/omf-web/widget/abstract_widget.rb', line 38 def () # Nothing end |
#widget_info ⇒ Object
Return text to provide information about this widget
30 31 32 |
# File 'lib/omf-web/widget/abstract_widget.rb', line 30 def () @opts[:info] || 'No information available' end |