Module: RailsWorkflow::OperationTemplates::DefaultBuilder

Extended by:
ActiveSupport::Concern
Included in:
RailsWorkflow::OperationTemplate
Defined in:
app/concerns/rails_workflow/operation_templates/default_builder.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (RailsWorkflow::Context) build_context(dependencies)

Building context for new operation using dependencies. By default it takes old operation's context copy for new operation. Independent operations have no previous operations so they use process context.

Main idea of this method is to have ability to use few dependencies context (merge context of few operations etc). In fact you can use #build_operation method to add all you need to context.

class NewOperationTemplate < RailsWorkflow::OperationTemplate
  def self.build_context operation
    context = dependencies.first.try(:context).try(:data)
    context[:user] = User.find(1) #adding user to context
    context[:isValid] = false # adding flag to context
  end
end

Returns:

See Also:



80
81
82
# File 'app/concerns/rails_workflow/operation_templates/default_builder.rb', line 80

def self.build_context dependencies
  dependencies.first.try(:context).try(:data)
end

Instance Method Details

- build_operation(operation)

This method returns an undefined value.

Used to customize operation. Also can be used to update operation context

class NewOperationTemplate < RailsWorkflow::OperationTemplate
  def build_operation operation
    operation.title += " ##{resource.id}"
    operation.data[:someFlag] = true # adding someFlag to operation context.
  end
end

Parameters:



18
19
20
# File 'app/concerns/rails_workflow/operation_templates/default_builder.rb', line 18

def build_operation operation
  #for customization
end