Sha256: 1c7c5c2336b1b42632d86a7068a7064871a13b0b8e40bb6ffbee159ca4823dfa

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

module Vedeu

  module Buffers

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

      include Vedeu::Common

      # @param (see #initialize)
      # @return (see #by_name)
      def self.by_name(name)
        new(name).by_name
      end

      # Return a new instance of Vedeu::Buffers::Refresh.
      #
      # @param name [String|Symbol] The name of the interface to be refreshed
      #   using the named buffer.
      # @return [Vedeu::Buffers::Refresh]
      def initialize(name)
        @name = name
      end

      # @return [Array|Vedeu::Error::ModelNotFound]
      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|Symbol]
      attr_reader :name

      private

      # @raise [Vedeu::Error::MissingRequired] When the name is empty
      #   or nil.
      # @return [String|Symbol]
      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

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.6.21 lib/vedeu/buffers/refresh.rb