Sha256: 2fcbedbe785df2ff6c6f65bf0b442507b5872b8afcfce4e44538ec760561f720

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

module Vedeu

  # When the client application has defined an interface to be used, the
  # Registrar stores the attributes into various repositories for later use.
  #
  # @api private
  class Registrar

    REPOSITORIES = [Buffers, Cursors, Groups, Interfaces, Offsets]

    # @param attributes [Hash]
    # @return [TrueClass|MissingRequired]
    def self.record(attributes = {})
      new(attributes).record
    end

    # Removes all entities from all repositories. Use with caution.
    #
    # @return [TrueClass]
    def self.reset!
      REPOSITORIES.each { |repository| repository.reset }

      true
    end

    # @param attributes [Hash]
    # @return [Registrar]
    def initialize(attributes = {})
      @attributes = attributes
    end

    # Adds the attributes to a variety of repositories to use later.
    #
    # @return [TrueClass|MissingRequired]
    def record
      focus

      REPOSITORIES.each { |repository| repository.add(attributes) }

      true
    end

    private

    attr_reader :attributes

    def focus
      Focus.add(attributes[:name], attributes[:focus])
    end

  end # Registrar

end # Vedeu

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.2.12 lib/vedeu/support/registrar.rb
vedeu-0.2.11 lib/vedeu/support/registrar.rb