Sha256: 5b7cfe45e1a6ec1580b27ad094783b32042ed1d36dd1c11132b7d1f10dc8a3ea

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

module Vedeu

  module Buffers

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

      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::Buffers::Refresh.
      #
      # @param name [String]
      # @return [Vedeu::Buffers::Refresh]
      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 # Refresh

  end # Buffers

end # Vedeu

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.6.8 lib/vedeu/buffers/refresh.rb
vedeu-0.6.7 lib/vedeu/buffers/refresh.rb