Sha256: 7beaa4388f91fc847a611d558aa5505e72aed44c97d188318d5efd123dfc684c

Contents?: true

Size: 1.34 KB

Versions: 14

Compression:

Stored size: 1.34 KB

Contents

module Vedeu

  # Provides the mechanism to render views for the client application.
  # The client application's ApplicationView will inherit from this
  # class.
  #
  class ApplicationView

    include Vedeu::View

    # Renders the view.
    #
    # @param params [Hash]
    # @return [void]
    def self.render(**params)
      new(params).render
    end

    # Returns a new instance of Vedeu::ApplicationView.
    #
    # @param params [Hash]
    # @return [Vedeu::ApplicationView]
    def initialize(**params)
      @params = params

      @params.each do |key, value|
        self.class.send(:define_method, key) { value } unless respond_to?(key)
      end
    end

    # @raise [Vedeu::Error::NotImplemented] Subclasses of this class
    #   must implement this method.
    def render
      fail Vedeu::Error::NotImplemented,
           'The subclass of Vedeu::ApplicationView must implement the #render' \
           'method.'
    end

    protected

    # @!attribute [rw] params
    # @return [Hash]
    attr_accessor :params

    private

    # Provides the path to the template file using the base_path
    # configuration option.
    #
    # @param value [String]
    # @return [String]
    def template(value)
      @template = Vedeu::Configuration.base_path +
                  "/app/views/templates/#{value}.erb"
    end

  end # ApplicationView

end # Vedeu

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
vedeu-0.6.20 lib/vedeu/application/application_view.rb
vedeu-0.6.19 lib/vedeu/application/application_view.rb
vedeu-0.6.18 lib/vedeu/application/application_view.rb
vedeu-0.6.17 lib/vedeu/application/application_view.rb
vedeu-0.6.16 lib/vedeu/application/application_view.rb
vedeu-0.6.15 lib/vedeu/application/application_view.rb
vedeu-0.6.14 lib/vedeu/application/application_view.rb
vedeu-0.6.13 lib/vedeu/application/application_view.rb
vedeu-0.6.12 lib/vedeu/application/application_view.rb
vedeu-0.6.11 lib/vedeu/application/application_view.rb
vedeu-0.6.10 lib/vedeu/application/application_view.rb
vedeu-0.6.9 lib/vedeu/application/application_view.rb
vedeu-0.6.8 lib/vedeu/application/application_view.rb
vedeu-0.6.7 lib/vedeu/application/application_view.rb