Sha256: 56a7fc73810c57504e704a363a44e5dd1442aec56cb492f5b044cf9dc7073939

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

# -*- encoding : utf-8 -*-
module MDWA
  module DSL
    
    class Process
      attr_accessor :description, :alias, :details, :start_for_roles
      
      def initialize(description) 
        self.description      = description
        
        # Hash: [detail_alias] => ProcessDetail object
        self.details          = {}
        # Hash: [role_alias] => detail_alias
        self.start_for_roles  = {}
      end
      
      def alias
        @alias ||= self.description.to_alias
      end
      
      def start_for(role, detail_alias)
        start_for_roles[role] = detail_alias
      end
      
      def detail(description)
        detail = ProcessDetail.new(self, description)
        self.details[detail.alias] = detail
        yield(detail) if block_given?
      end
      
      # 
      # Return the ProcessDetail based on alias, or entity and action.
      # Params:
      # :alias => detail alias
      # :entity
      # :action
      def process_detail(options = {})
        detail = self.details[options[:alias]] unless options[:alias].blank?
        if detail.nil?
          self.details.values.each do |d|
            if( d.detail_action.entity == options[:entity] and d.detail_action.action == options[:action] )
              detail = d
              break
            end
          end
        end
        return detail
      end
      
    end
    
  end # dsl
end # mdwa

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mdd-3.1.0 lib/mdwa/dsl/process.rb
mdd-3.0.20 lib/mdwa/dsl/process.rb
mdd-3.0.19 lib/mdwa/dsl/process.rb