Sha256: eb6ff51ed09bda6387917bfcb3680f010c482d73653fdb1dc70f70297f4b8dce

Contents?: true

Size: 1.38 KB

Versions: 13

Compression:

Stored size: 1.38 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.gsub(' ', '_').underscore
      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

13 entries across 13 versions & 1 rubygems

Version Path
mdd-3.0.18 lib/mdwa/dsl/process.rb
mdd-3.0.17 lib/mdwa/dsl/process.rb
mdd-3.0.16 lib/mdwa/dsl/process.rb
mdd-3.0.15 lib/mdwa/dsl/process.rb
mdd-3.0.14 lib/mdwa/dsl/process.rb
mdd-3.0.13 lib/mdwa/dsl/process.rb
mdd-3.0.10 lib/mdwa/dsl/process.rb
mdd-3.0.9 lib/mdwa/dsl/process.rb
mdd-3.0.8 lib/mdwa/dsl/process.rb
mdd-3.0.7 lib/mdwa/dsl/process.rb
mdd-3.0.6 lib/mdwa/dsl/process.rb
mdd-3.0.4 lib/mdwa/dsl/process.rb
mdd-3.0.3 lib/mdwa/dsl/process.rb