Sha256: 338f13459b96f17fe0c6741151cb629ace3b640662b381648ac987d76bd3b2a1

Contents?: true

Size: 1.32 KB

Versions: 10

Compression:

Stored size: 1.32 KB

Contents

require 'erector'
require 'omf_base/lobject'

module OMF::Web::Widget
      
  # Maintains the context for a particular code rendering within a specific session.
  #
  class AbstractWidget < Erector::Widget
    extend OMF::Base::Loggable
    include OMF::Base::Loggable    
    
    attr_reader :widget_id, :widget_type, :name, :opts
    
    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
    
    # Return text to provide information about this widget
    #
    def widget_info()
      @opts[:info] || 'No information available'
    end
    

    # Return html for an optional widget tools menu to be added
    # to the widget decoration by the theme.
    # 
    def tools_menu()
      # Nothing
    end
    
    def layout?
      return false
    end
    
    def title
      @opts[:title]
    end
    
    def mime_type
      @opts[:mime_type] || 'unknown'
    end
    
    def collect_data_sources(ds_set)
      raise "Should have been implemented"
    end
    
    
        
  end # class
    

end # OMF::Web::Widget

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
omf_web-1.2.9 lib/omf-web/widget/abstract_widget.rb
omf_web-1.2.8 lib/omf-web/widget/abstract_widget.rb
omf_web-1.2.7 lib/omf-web/widget/abstract_widget.rb
omf_web-1.2.6 lib/omf-web/widget/abstract_widget.rb
omf_web-1.2.5 lib/omf-web/widget/abstract_widget.rb
omf_web-1.2.4 lib/omf-web/widget/abstract_widget.rb
omf_web-1.2.3 lib/omf-web/widget/abstract_widget.rb
omf_web-1.2.2 lib/omf-web/widget/abstract_widget.rb
omf_web-1.2.1 lib/omf-web/widget/abstract_widget.rb
omf_web-1.2.0 lib/omf-web/widget/abstract_widget.rb