Module: Mxrb::Dsl::FlowBodyDsl

Included in:
BranchBuilder, FlowBuilder, LoopBuilder, RescueBuilder
Defined in:
lib/mxrb/dsl/builder.rb

Overview

Shared activity DSL mixed into FlowBuilder, BranchBuilder, LoopBuilder, RescueBuilder

Instance Method Summary collapse

Instance Method Details

#aggregate(list, function:, as:, attribute: nil) ⇒ Object



1281
1282
1283
1284
1285
1286
# File 'lib/mxrb/dsl/builder.rb', line 1281

def aggregate(list, function:, as:, attribute: nil)
  _acts << {
    type: :aggregate, variable: list.to_s, function: function.to_s,
    output: as.to_s, attribute: attribute.to_s
  }
end

#call_microflow(name, as: nil, pass: {}, result_name: nil, use_return: nil) ⇒ Object



1215
1216
1217
1218
1219
1220
1221
1222
1223
# File 'lib/mxrb/dsl/builder.rb', line 1215

def call_microflow(name, as: nil, pass: {}, result_name: nil, use_return: nil)
  mappings = pass.map { |param, var| { param: param.to_s, value: var } }
  _acts << {
    type: :call_microflow, name: name.to_s, variable: as&.to_s,
    result_name: result_name&.to_s,
    use_return: use_return.nil? ? !as.nil? : use_return == true,
    mappings: mappings
  }
end

#call_rest(method:, location:, location_parameters: [], headers: {}, request_mapping: nil, request_variable: nil, result_mapping: nil, as: nil, result_entity: nil, timeout: nil, commit: :yes_without_events, error_result: :http_response, error: :rollback) ⇒ Object



1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
# File 'lib/mxrb/dsl/builder.rb', line 1325

def call_rest(method:, location:, location_parameters: [], headers: {},
              request_mapping: nil, request_variable: nil,
              result_mapping: nil, as: nil, result_entity: nil,
              timeout: nil, commit: :yes_without_events,
              error_result: :http_response, error: :rollback)
  _acts << {
    type: :call_rest, method: method.to_s, location: location.to_s,
    location_parameters: Array(location_parameters),
    headers: headers.transform_keys(&:to_s),
    request_mapping: request_mapping&.to_s,
    request_variable: request_variable&.to_s,
    result_mapping: result_mapping&.to_s, variable: as&.to_s,
    result_entity: result_entity&.to_s, timeout: timeout&.to_s,
    commit: commit.to_s, error_result: error_result.to_s,
    error: error.to_s
  }
end

#cast(variable) ⇒ Object



1292
1293
1294
# File 'lib/mxrb/dsl/builder.rb', line 1292

def cast(variable)
  _acts << { type: :cast, variable: variable.to_s }
end

#change_list(list, action:, value:) ⇒ Object



1308
1309
1310
1311
1312
1313
# File 'lib/mxrb/dsl/builder.rb', line 1308

def change_list(list, action:, value:)
  _acts << {
    type: :change_list, variable: list.to_s,
    action: action.to_s, value: value
  }
end

#change_object(variable, set: {}, commit: false, with_events: true, refresh: false, &block) ⇒ Object



1184
1185
1186
1187
1188
1189
# File 'lib/mxrb/dsl/builder.rb', line 1184

def change_object(variable, set: {}, commit: false, with_events: true,
                  refresh: false, &block)
  _acts << { type: :change_object, variable: variable.to_s,
             members: _build_members(set, &block), commit: commit,
             with_events: with_events, refresh: refresh }
end

#change_variable(name, to:) ⇒ Object



1245
1246
1247
# File 'lib/mxrb/dsl/builder.rb', line 1245

def change_variable(name, to:)
  _acts << { type: :change_variable, variable: name.to_s, value: to }
end

#close_page(count: nil) ⇒ Object



1277
1278
1279
# File 'lib/mxrb/dsl/builder.rb', line 1277

def close_page(count: nil)
  _acts << { type: :close_page, count: count }
end

#commit(variable, with_events: true, refresh: false) ⇒ Object



1204
1205
1206
1207
1208
1209
# File 'lib/mxrb/dsl/builder.rb', line 1204

def commit(variable, with_events: true, refresh: false)
  _acts << {
    type: :commit, variable: variable.to_s,
    with_events: with_events, refresh: refresh
  }
end

#continue_loopObject



1356
1357
1358
# File 'lib/mxrb/dsl/builder.rb', line 1356

def continue_loop
  _acts << { type: :continue_event }
end

#create_list(entity, as:) ⇒ Object



1296
1297
1298
# File 'lib/mxrb/dsl/builder.rb', line 1296

def create_list(entity, as:)
  _acts << { type: :create_list, entity: entity.to_s, variable: as.to_s }
end

#create_object(entity, as:, set: {}, commit: false, with_events: true, refresh: false, &block) ⇒ Object



1177
1178
1179
1180
1181
1182
# File 'lib/mxrb/dsl/builder.rb', line 1177

def create_object(entity, as:, set: {}, commit: false, with_events: true,
                  refresh: false, &block)
  _acts << { type: :create_object, entity: entity.to_s, variable: as.to_s,
             members: _build_members(set, &block), commit: commit,
             with_events: with_events, refresh: refresh }
end

#create_variable(name, type: nil, value: nil) ⇒ Object



1238
1239
1240
1241
1242
1243
# File 'lib/mxrb/dsl/builder.rb', line 1238

def create_variable(name, type: nil, value: nil)
  _acts << {
    type: :create_variable, variable: name.to_s,
    variable_type: type&.to_s, value: value
  }
end

#decision(condition, &block) ⇒ Object



1369
1370
1371
1372
1373
# File 'lib/mxrb/dsl/builder.rb', line 1369

def decision(condition, &block)
  db = DecisionBuilder.new(condition.is_a?(Hash) ? condition : condition.to_s)
  db.instance_eval(&block) if block
  _acts << db.to_h
end

#delete(variable, refresh: false) ⇒ Object



1211
1212
1213
# File 'lib/mxrb/dsl/builder.rb', line 1211

def delete(variable, refresh: false)
  _acts << { type: :delete_object, variable: variable.to_s, refresh: refresh }
end

#end_flowObject



1348
1349
1350
# File 'lib/mxrb/dsl/builder.rb', line 1348

def end_flow
  _acts << { type: :return_event, expression: "" }
end

#error_eventObject



1352
1353
1354
# File 'lib/mxrb/dsl/builder.rb', line 1352

def error_event
  _acts << { type: :error_event }
end

#list_operation(operation, list, as:, with: nil, expression: nil) ⇒ Object



1300
1301
1302
1303
1304
1305
1306
# File 'lib/mxrb/dsl/builder.rb', line 1300

def list_operation(operation, list, as:, with: nil, expression: nil)
  _acts << {
    type: :list_operation, operation: operation.to_s,
    variable: list.to_s, second: with&.to_s,
    expression: expression&.to_s, output: as.to_s
  }
end

#log_message(message, level: :info, node: nil, include_stack: false, parameters: []) ⇒ Object



1259
1260
1261
1262
1263
1264
1265
# File 'lib/mxrb/dsl/builder.rb', line 1259

def log_message(message, level: :info, node: nil, include_stack: false, parameters: [])
  _acts << {
    type: :log_message, message: message.to_s, level: level.to_s,
    node: node&.to_s, include_stack: include_stack,
    parameters: Array(parameters)
  }
end

#loop_over(variable, as: nil, &block) ⇒ Object



1381
1382
1383
1384
1385
# File 'lib/mxrb/dsl/builder.rb', line 1381

def loop_over(variable, as: nil, &block)
  lb = LoopBuilder.new(variable.to_s, as: (as || variable).to_s)
  lb.instance_eval(&block) if block
  _acts << lb.to_h
end

#rescue_all(&block) ⇒ Object



1360
1361
1362
1363
1364
1365
1366
1367
# File 'lib/mxrb/dsl/builder.rb', line 1360

def rescue_all(&block)
  rescue_builder = RescueBuilder.new
  rescue_builder.instance_eval(&block) if block
  _acts << {
    type: :rescue_all,
    activities: rescue_builder.activities
  }
end

#retrieve_association(from, association:, as:) ⇒ Object



1197
1198
1199
1200
1201
1202
# File 'lib/mxrb/dsl/builder.rb', line 1197

def retrieve_association(from, association:, as:)
  _acts << {
    type: :retrieve_association, variable: as.to_s,
    start_variable: from.to_s, association: association.to_s
  }
end

#retrieve_objects(entity, as:, xpath: nil, limit: nil, single: false, sort: []) ⇒ Object



1191
1192
1193
1194
1195
# File 'lib/mxrb/dsl/builder.rb', line 1191

def retrieve_objects(entity, as:, xpath: nil, limit: nil, single: false, sort: [])
  _acts << { type: :retrieve_objects, entity: entity.to_s, variable: as.to_s,
             xpath: xpath&.to_s, limit: limit, single: single,
             sortings: Array(sort) }
end

#return_value(value) ⇒ Object



1343
1344
1345
1346
# File 'lib/mxrb/dsl/builder.rb', line 1343

def return_value(value)
  expression = value.is_a?(Symbol) ? "$#{value}" : value.to_s
  _acts << { type: :return_event, expression: expression }
end

#rollback(variable, refresh: false) ⇒ Object



1288
1289
1290
# File 'lib/mxrb/dsl/builder.rb', line 1288

def rollback(variable, refresh: false)
  _acts << { type: :rollback, variable: variable.to_s, refresh: refresh }
end

#show_message(text = nil, type: :information, blocking: false, translations: nil, parameters: []) ⇒ Object



1249
1250
1251
1252
1253
1254
1255
1256
1257
# File 'lib/mxrb/dsl/builder.rb', line 1249

def show_message(text = nil, type: :information, blocking: false,
                 translations: nil, parameters: [])
  _acts << {
    type: :show_message, text: text.to_s, message_type: type.to_s,
    blocking: blocking,
    translations: translations&.transform_keys(&:to_s),
    parameters: Array(parameters)
  }
end

#show_page(page, object: nil, location: nil, pass: {}, close_pages: nil, title: nil) ⇒ Object



1267
1268
1269
1270
1271
1272
1273
1274
1275
# File 'lib/mxrb/dsl/builder.rb', line 1267

def show_page(page, object: nil, location: nil, pass: {}, close_pages: nil,
              title: nil)
  _acts << {
    type: :show_page, page: page.to_s, variable: object&.to_s,
    location: location&.to_s,
    mappings: pass.map { |parameter, value| { parameter: parameter.to_s, value: value } },
    close_pages: close_pages, title: title
  }
end

#type_decision(variable, &block) ⇒ Object



1375
1376
1377
1378
1379
# File 'lib/mxrb/dsl/builder.rb', line 1375

def type_decision(variable, &block)
  builder = TypeDecisionBuilder.new(variable.to_s)
  builder.instance_eval(&block) if block
  _acts << builder.to_h
end

#validation_feedback(variable, attribute: nil, association: nil, translations: {}, parameters: [], error: :rollback) ⇒ Object



1315
1316
1317
1318
1319
1320
1321
1322
1323
# File 'lib/mxrb/dsl/builder.rb', line 1315

def validation_feedback(variable, attribute: nil, association: nil,
                        translations: {}, parameters: [], error: :rollback)
  _acts << {
    type: :validation_feedback, variable: variable.to_s,
    attribute: attribute.to_s, association: association.to_s,
    translations: translations.transform_keys(&:to_s),
    parameters: Array(parameters), error: error.to_s
  }
end

#while_loop(condition, &block) ⇒ Object



1387
1388
1389
1390
1391
1392
1393
1394
# File 'lib/mxrb/dsl/builder.rb', line 1387

def while_loop(condition, &block)
  lb = LoopBuilder.new(nil, as: nil)
  lb.instance_eval(&block) if block
  item = lb.to_h
  item[:type] = :while_loop
  item[:condition] = condition.to_s
  _acts << item
end