Sha256: d65695b617e99b20457d660701fc8f2c065b823412d55998314ecbbb9dad9e04

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module Vedeu

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

    include Vedeu::View

    # Renders the view.
    #
    # @param (see #initialize)
    # @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

    # @macro raise_not_implemented
    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.config.base_path +
                  "/app/views/templates/#{value}.erb"
    end

  end # ApplicationView

end # Vedeu

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.8.12 lib/vedeu/application/application_view.rb