Sha256: c3f742750ded09ce97d69e8d4cf02a06614145059201a61632d45d5d19b283ca

Contents?: true

Size: 713 Bytes

Versions: 3

Compression:

Stored size: 713 Bytes

Contents

module Suricate
  class Widget
    extend Forwardable
    attr_reader :id, :options, :collector

    def initialize(options = {})
      @id        = options[:id]
      @context   = options[:context]
      @options   = options[:options]
      @collector = options[:collector]
    end

    class << self
      def type
        name.match(/(?:::)?(\w+)$/)[1]
      end
    end

    def type
      self.class.type
    end

    def execute
      raise NotImplementedError.new('Suricate::Widget is a template class, #execute must be implamented in subclass')
    end

    private
    def_delegators :@context, :request, :params, :session, :output
    def_delegators :output, :render, :api_success, :api_error
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
suricate-0.0.4 lib/suricate/widgets/widget.rb
suricate-0.0.3 lib/suricate/widgets/widget.rb
suricate-0.0.2 lib/suricate/widgets/widget.rb