Sha256: b95d874a4403f2bfb1d2e6d6b222fc6bba33ce1e1580e11feb79b905759c0c60

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 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
      
      def clear
        @nodes.clear
      end

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

    
  end # dsl
end # mdd

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mdd-3.1.4 lib/mdwa/dsl/requirements.rb
mdd-3.1.2 lib/mdwa/dsl/requirements.rb
mdd-3.1.1 lib/mdwa/dsl/requirements.rb