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



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

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



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

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



1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
# File 'lib/mxrb/dsl/builder.rb', line 1423

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



1390
1391
1392
# File 'lib/mxrb/dsl/builder.rb', line 1390

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

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



1406
1407
1408
1409
1410
1411
# File 'lib/mxrb/dsl/builder.rb', line 1406

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



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

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



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

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

#close_page(count: nil) ⇒ Object



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

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

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



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

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

#continue_loopObject



1454
1455
1456
# File 'lib/mxrb/dsl/builder.rb', line 1454

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

#create_list(entity, as:) ⇒ Object



1394
1395
1396
# File 'lib/mxrb/dsl/builder.rb', line 1394

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



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

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



1336
1337
1338
1339
1340
1341
# File 'lib/mxrb/dsl/builder.rb', line 1336

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



1467
1468
1469
1470
1471
# File 'lib/mxrb/dsl/builder.rb', line 1467

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



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

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

#end_flowObject



1446
1447
1448
# File 'lib/mxrb/dsl/builder.rb', line 1446

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

#error_eventObject



1450
1451
1452
# File 'lib/mxrb/dsl/builder.rb', line 1450

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

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



1398
1399
1400
1401
1402
1403
1404
# File 'lib/mxrb/dsl/builder.rb', line 1398

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



1357
1358
1359
1360
1361
1362
1363
# File 'lib/mxrb/dsl/builder.rb', line 1357

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



1479
1480
1481
1482
1483
# File 'lib/mxrb/dsl/builder.rb', line 1479

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



1458
1459
1460
1461
1462
1463
1464
1465
# File 'lib/mxrb/dsl/builder.rb', line 1458

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



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

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



1289
1290
1291
1292
1293
# File 'lib/mxrb/dsl/builder.rb', line 1289

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



1441
1442
1443
1444
# File 'lib/mxrb/dsl/builder.rb', line 1441

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



1386
1387
1388
# File 'lib/mxrb/dsl/builder.rb', line 1386

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



1347
1348
1349
1350
1351
1352
1353
1354
1355
# File 'lib/mxrb/dsl/builder.rb', line 1347

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



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

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



1473
1474
1475
1476
1477
# File 'lib/mxrb/dsl/builder.rb', line 1473

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



1413
1414
1415
1416
1417
1418
1419
1420
1421
# File 'lib/mxrb/dsl/builder.rb', line 1413

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



1485
1486
1487
1488
1489
1490
1491
1492
# File 'lib/mxrb/dsl/builder.rb', line 1485

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