Sha256: ad9767d81726003c91d5317028ecefb58b84080fde3375da208cbada4b5cd70e

Contents?: true

Size: 1.56 KB

Versions: 3

Compression:

Stored size: 1.56 KB

Contents

# -*- encoding : utf-8 -*-
require 'ostruct'
require 'extensions/string'

module MDWA
  module DSL
    
    class ProcessDetail
      attr_accessor :process, :description, :alias, :user_roles, :detail_action, :next_actions
      
      def initialize(process, description)
        self.process      = process
        self.description  = description
        
        self.user_roles   = []
        self.next_actions = []
        self.detail_action = OpenStruct.new
      end
      
      # Unique alias for detailing
      # Default: Detail name underscored
      def alias
        @alias ||= self.description.to_alias
      end
      
      # Refered action
      # Params: 
      # => :entity
      # => :action
      def action(entity, action)
        self.detail_action.entity = entity
        self.detail_action.action = action
      end
      
      # Possible next action
      # Params: 
      # => :alias
      # => :entity
      # => :action
      # => :method
      # => :request
      # => :redirect  => boolean
      # => :render    => boolean
      # => :when - situation when it might occur
      def next_action(detail_alias, options = {})
        next_action = ProcessDetailNextAction.new(detail_alias)
        next_action.method    = options[:method] || :get
        next_action.request   = options[:request] || :html
        next_action.redirect  = options[:redirect] || false
        next_action.render    = options[:render] || false
        next_action.when      = options[:when]

        next_actions << next_action
      end
            
    end
    
  end # dsl
end # mdwa

Version data entries

3 entries across 3 versions & 1 rubygems

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