Sha256: 350d60a820f2c2d7a8ebc2b4049cda071a594e9fe007cddf702277945f7c1c2e

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 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 if Vedeu.ready?
      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

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.6.15 lib/vedeu/buffers/refresh.rb
vedeu-0.6.14 lib/vedeu/buffers/refresh.rb
vedeu-0.6.13 lib/vedeu/buffers/refresh.rb
vedeu-0.6.12 lib/vedeu/buffers/refresh.rb