Class: LcpRuby::Dsl::WorkflowBuilder::ApprovalBlockContext

Inherits:
Object
  • Object
show all
Defined in:
lib/lcp_ruby/dsl/workflow_builder.rb

Instance Method Summary collapse

Constructor Details

#initializeApprovalBlockContext

Returns a new instance of ApprovalBlockContext.



117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/lcp_ruby/dsl/workflow_builder.rb', line 117

def initialize
  @strategy_value = nil
  @resolution_value = {}
  @bypass_when_value = nil
  @on_reject_value = nil
  @short_circuit_value = nil
  @rework_policy_value = nil
  @allow_delegation_value = nil
  @delegation_roles_value = nil
  @max_delegation_depth_value = nil
  @require_reject_comment_value = nil
  @allow_approve_with_comment_value = nil
  @steps = []
end

Instance Method Details

#allow_approve_with_comment(value = true) ⇒ Object



172
173
174
# File 'lib/lcp_ruby/dsl/workflow_builder.rb', line 172

def allow_approve_with_comment(value = true)
  @allow_approve_with_comment_value = value
end

#allow_delegation(value = true) ⇒ Object



156
157
158
# File 'lib/lcp_ruby/dsl/workflow_builder.rb', line 156

def allow_delegation(value = true)
  @allow_delegation_value = value
end

#bypass_when(condition) ⇒ Object



140
141
142
# File 'lib/lcp_ruby/dsl/workflow_builder.rb', line 140

def bypass_when(condition)
  @bypass_when_value = condition.is_a?(Hash) ? HashUtils.stringify_deep(condition) : condition
end

#delegation_roles(*roles) ⇒ Object



160
161
162
# File 'lib/lcp_ruby/dsl/workflow_builder.rb', line 160

def delegation_roles(*roles)
  @delegation_roles_value = roles.flatten.map(&:to_s)
end

#max_delegation_depth(value) ⇒ Object



164
165
166
# File 'lib/lcp_ruby/dsl/workflow_builder.rb', line 164

def max_delegation_depth(value)
  @max_delegation_depth_value = value
end

#on_reject(value) ⇒ Object



144
145
146
# File 'lib/lcp_ruby/dsl/workflow_builder.rb', line 144

def on_reject(value)
  @on_reject_value = value.to_s
end

#require_reject_comment(value = true) ⇒ Object



168
169
170
# File 'lib/lcp_ruby/dsl/workflow_builder.rb', line 168

def require_reject_comment(value = true)
  @require_reject_comment_value = value
end

#resolution(hash) ⇒ Object



136
137
138
# File 'lib/lcp_ruby/dsl/workflow_builder.rb', line 136

def resolution(hash)
  @resolution_value = hash.transform_keys(&:to_s)
end

#rework_policy(hash) ⇒ Object



152
153
154
# File 'lib/lcp_ruby/dsl/workflow_builder.rb', line 152

def rework_policy(hash)
  @rework_policy_value = hash.transform_keys(&:to_s)
end

#short_circuit(value = true) ⇒ Object



148
149
150
# File 'lib/lcp_ruby/dsl/workflow_builder.rb', line 148

def short_circuit(value = true)
  @short_circuit_value = value
end

#step(name, label: nil, &block) ⇒ Object



176
177
178
179
180
# File 'lib/lcp_ruby/dsl/workflow_builder.rb', line 176

def step(name, label: nil, &block)
  ctx = StepBlockContext.new(name, label)
  ctx.instance_eval(&block) if block
  @steps << ctx.to_hash
end

#strategy(value) ⇒ Object



132
133
134
# File 'lib/lcp_ruby/dsl/workflow_builder.rb', line 132

def strategy(value)
  @strategy_value = value.to_s
end

#to_hashObject



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/lcp_ruby/dsl/workflow_builder.rb', line 182

def to_hash
  hash = {}
  hash["strategy"] = @strategy_value if @strategy_value
  hash["resolution"] = @resolution_value unless @resolution_value.empty?
  hash["bypass_when"] = @bypass_when_value if @bypass_when_value
  hash["on_reject"] = @on_reject_value if @on_reject_value
  hash["short_circuit"] = @short_circuit_value unless @short_circuit_value.nil?
  hash["rework_policy"] = @rework_policy_value if @rework_policy_value
  hash["allow_delegation"] = @allow_delegation_value unless @allow_delegation_value.nil?
  hash["delegation_roles"] = @delegation_roles_value if @delegation_roles_value
  hash["max_delegation_depth"] = @max_delegation_depth_value if @max_delegation_depth_value
  hash["require_reject_comment"] = @require_reject_comment_value unless @require_reject_comment_value.nil?
  hash["allow_approve_with_comment"] = @allow_approve_with_comment_value unless @allow_approve_with_comment_value.nil?
  hash["steps"] = @steps unless @steps.empty?
  hash
end