Sha256: 606ef427d1a8dedc0bdba7e1bcba4d459bb46a9ca91351d8637a3e9eadba63af

Contents?: true

Size: 1.47 KB

Versions: 8

Compression:

Stored size: 1.47 KB

Contents

module Vedeu

  # Subclassing Vedeu::View will allow Vedeu to call your #render method.
  # This method should contain attributes required to build a view or views.
  # These attributes will be added to the back buffer of each interface
  # mentioned, to be rendered upon next refresh.
  #
  # @deprecated May disappear in 0.3.0. Prefer {Vedeu::API#render} instead.
  # @see Vedeu::API#render
  # @api private
  class View

    include Vedeu::API

    # @param object []
    # @return [Array]
    def self.render(object = nil)
      new(object).enqueue
    end

    # Returns a new instance of View.
    #
    # @param object []
    # @return [View]
    def initialize(object = nil)
      @object = object
    end

    # @return [Array]
    def enqueue
      composition.interfaces.map do |interface|
        Buffers.add(interface.attributes)
      end
    end

    # @raise [NotImplemented] Subclasses of this class must implement this
    #   method.
    # @return [Exception]
    def render
      fail NotImplemented, 'Implement #render on your subclass of Vedeu::View.'
    end

    private

    attr_reader :object

    # Create a new Composition object with the attributes.
    #
    # @return [Composition]
    def composition
      @_composition ||= Composition.new(attributes)
    end

    # Calls the #render method of the subclass, hopefully receives attributes
    # suitable to create one or more views.
    #
    # @return []
    def attributes
      render
    end

  end # View

end # Vedeu

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vedeu-0.2.11 lib/vedeu/output/view.rb
vedeu-0.2.10 lib/vedeu/output/view.rb
vedeu-0.2.9 lib/vedeu/output/view.rb
vedeu-0.2.8 lib/vedeu/output/view.rb
vedeu-0.2.7 lib/vedeu/output/view.rb
vedeu-0.2.6 lib/vedeu/output/view.rb
vedeu-0.2.5 lib/vedeu/output/view.rb
vedeu-0.2.4 lib/vedeu/output/view.rb