Sha256: 8473623c42893b080ff3d61b532f681014e88f963c4b0df901afd330b0b96842

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

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

    # singleton class
    class Workflow
      
      attr_accessor :nodes
      
      def initialize
        @nodes ||= {}
      end
      
      def self.instance
        @__instance__ ||= new
      end
      
      #
      # Register a new user in the list.
      #
      def register( name )
        # retrive or initialize a entity
        process = element(name) || Process.new( name )
        yield(process) if block_given?
        add_node process # 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 entitites
    
    # return the entities instance
    def self.workflow
      Workflow.instance
    end
    
    def self.process(name)
      self.workflow.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/workflow.rb
mdd-3.1.2 lib/mdwa/dsl/workflow.rb
mdd-3.1.1 lib/mdwa/dsl/workflow.rb