Sha256: c12c983eddc48419a1d31474e5a65dd4087b7e2ec8c30f7cc3b48d1525af6f1b

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

module Vedeu

  # Refreshes the given named interface.
  #
  # @example
  #   Vedeu.trigger(:_refresh_, name)
  #
  class RefreshBuffer

    include Vedeu::Common

    # @param name [String] The name of the interface to be refreshed using the
    #   named buffer.
    # @return [Array|Vedeu::Error::ModelNotFound]
    def self.by_name(name)
      new(name).by_name
    end

    # Return a new instance of Vedeu::RefreshBuffer.
    #
    # @param name [String]
    # @return [Vedeu::RefreshBuffer]
    def initialize(name)
      @name = name
    end

    # @return [void]
    def by_name
      Vedeu.timer("Refresh Buffer: '#{buffer_name}'") do
        Vedeu.buffers.by_name(buffer_name).render
      end
    end

    protected

    # # @!attribute [r] name
    # @return [String]
    attr_reader :name

    private

    # @raise [Vedeu::Error::MissingRequired] When the name is empty or nil.
    # @return [String]
    def buffer_name
      return name if present?(name)

      fail Vedeu::Error::MissingRequired,
           'Cannot refresh interface with an empty interface name.'
    end

  end # RefreshBuffer

end # Vedeu

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vedeu-0.6.6 lib/vedeu/refresh/refresh_buffer.rb
vedeu-0.6.5 lib/vedeu/refresh/refresh_buffer.rb
vedeu-0.6.4 lib/vedeu/refresh/refresh_buffer.rb
vedeu-0.6.3 lib/vedeu/refresh/refresh_buffer.rb
vedeu-0.6.2 lib/vedeu/refresh/refresh_buffer.rb