Class: OMF::Web::Widget::AbstractWidget

Inherits:
Erector::Widget
  • Object
show all
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.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/omf-web/widget/abstract_widget.rb', line 13

def name
  @name
end

#optsObject (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_idObject (readonly)

Returns the value of attribute widget_id.



13
14
15
# File 'lib/omf-web/widget/abstract_widget.rb', line 13

def widget_id
  @widget_id
end

#widget_typeObject (readonly)

Returns the value of attribute widget_type.



13
14
15
# File 'lib/omf-web/widget/abstract_widget.rb', line 13

def widget_type
  @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

Returns:

  • (Boolean)


42
43
44
# File 'lib/omf-web/widget/abstract_widget.rb', line 42

def layout?
  return false
end

#mime_typeObject



50
51
52
# File 'lib/omf-web/widget/abstract_widget.rb', line 50

def mime_type
  @opts[:mime_type] || 'unknown'
end

#titleObject



46
47
48
# File 'lib/omf-web/widget/abstract_widget.rb', line 46

def title
  @opts[:title]
end

#tools_menuObject

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 tools_menu()
  # Nothing
end

#widget_infoObject

Return text to provide information about this widget



30
31
32
# File 'lib/omf-web/widget/abstract_widget.rb', line 30

def widget_info()
  @opts[:info] || 'No information available'
end