Sha256: 8f4565429561867566023f75d88a64383a077d0978fc81d55a0a449db1b23511

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

# -*- encoding : utf-8 -*-
module MDWA
  module DSL

    # singleton class
    class Requirements
      
      attr_accessor :nodes
      
      def initialize
        @nodes ||= {}
      end
      
      def self.instance
        @__instance__ ||= new
      end
      
      #
      # Register a new requirement in the list.
      #
      def register( summary = nil )
        # retrive or initialize a entity
        req = Requirement.new( summary )
        yield(req) if block_given?
        add_node(req) # add to the list
      end
    
      #
      # Add note to the entity list
      # Prevents entity duplication
      #
      def add_node(node)
        @nodes[node.alias] = node
      end
      
      def element(e)
        @nodes[e]
      end
      
      def all
        @nodes.values
      end

    end # class
    
    # return the requirements instance
    def self.requirements
      Requirements.instance
    end
    
    def self.requirement(name)
      self.requirements.element(name)
    end

    
  end # dsl
end # mdd

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mdd-3.0.6 lib/mdwa/dsl/requirements.rb
mdd-3.0.4 lib/mdwa/dsl/requirements.rb
mdd-3.0.3 lib/mdwa/dsl/requirements.rb