Sha256: 44bdf6780b718728fef3501a384e1d404b7921c71bbbd06b48605a690bc90155

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

module Vedeu

  # Repository for storing, retrieving and manipulating the cursor position and
  # visibility for an interface.
  #
  # @api private
  module Cursors

    include Repository
    extend self

    # Add or update the cursor coordinates.
    #
    # @param attributes [Hash]
    # @return [Offset]
    def add(attributes)
      validate_attributes!(attributes)

      Vedeu.log("#{action(__callee__)} positional (#{model}): " \
                "'#{attributes[:name]}'")

      model.new(attributes).store
    end
    alias_method :update, :add

    # Make the cursor of this interface invisible.
    #
    # @return [Cursor]
    def hide
      find_or_create(Focus.current).hide
    end

    # Make the cursor of this interface visible.
    #
    # @return [Cursor]
    def show
      find_or_create(Focus.current).show
    end

    private

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

    # Returns an empty collection ready for the storing of cursors by name with
    # current attributes.
    #
    # @example
    #   { 'holmium' => {
    #                    name:     'holmium',
    #                    state:    :show,
    #                    x:        1,
    #                    y:        1 } }
    #
    # @return [Hash]
    def in_memory
      {}
    end

  end # Cursors

end # Vedeu

Version data entries

2 entries across 2 versions & 1 rubygems

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