Sha256: 8ade42ec0cce55efb5f10863bd777265e9ea4525e4ef89a43fce0f512c499753

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

module Vedeu

  # Stores interface views to be later combined with interface geometry to be
  # displayed.
  #
  # @api private
  module Buffers

    include Repository
    extend self

    # Add an interface view into the back buffer. If the buffer is already
    # registered, then we preserve its front buffer. Returns the name of the
    # buffer added to storage.
    #
    # @param attributes [Hash]
    # @return [String] The name of the buffer that has been added.
    def add(attributes)
      validate_attributes!(attributes)

      name = attributes[:name]

      if registered?(name)
        Vedeu.log("Adding new content to existing buffer: '#{name}'")

        find(name).add(attributes)

      else
        Vedeu.log("Adding new buffer: '#{name}'")

        model.new({ name: name }).add(attributes)

      end

      name
    end

    private

    # @return [Class] The model class for this repository.
    def model
      Vedeu::Buffer
    end

    # @return [Hash]
    def in_memory
      {}
    end

  end # Buffers

end # Vedeu

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.2.12 lib/vedeu/repositories/buffers.rb
vedeu-0.2.11 lib/vedeu/repositories/buffers.rb