Sha256: 67cdc61c52649feaa325d195988c22b04c3e5f003a2b1b9cbb07470ade901dce

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 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, Focus, 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
      REPOSITORIES.each { |repository| repository.add(attributes) }

      true
    end

    private

    attr_reader :attributes

  end # Registrar

end # Vedeu

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.2.10 lib/vedeu/support/registrar.rb