Class: Mxrb::Dsl::FlowBuilder
- Inherits:
-
Object
- Object
- Mxrb::Dsl::FlowBuilder
show all
- Includes:
- FlowBodyDsl
- Defined in:
- lib/mxrb/dsl/builder.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#aggregate, #call_microflow, #call_rest, #cast, #change_list, #change_object, #change_variable, #close_page, #commit, #continue_loop, #create_list, #create_object, #create_variable, #decision, #delete, #end_flow, #error_event, #list_operation, #log_message, #loop_over, #retrieve_association, #retrieve_objects, #rollback, #show_message, #show_page, #type_decision, #validation_feedback, #while_loop
Constructor Details
#initialize(name, runtime:, kind:, public:) ⇒ FlowBuilder
Returns a new instance of FlowBuilder.
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
|
# File 'lib/mxrb/dsl/builder.rb', line 1510
def initialize(name, runtime:, kind:, public:)
@name = name.to_s
@runtime = runtime
@kind = kind
@public = public
@parameters = []
@return_type = nil
@doc = ""
@calls = []
@repositories = []
@allowed_roles = nil
@body = nil
@return_variable_name = nil
@return_expression = nil
@expected_body_fingerprint = nil
@allow_concurrent_execution = nil
@mark_as_used = nil
@excluded = nil
end
|
Class Method Details
.body_digest(body, return_expression) ⇒ Object
1577
1578
1579
1580
|
# File 'lib/mxrb/dsl/builder.rb', line 1577
def self.body_digest(body, return_expression)
payload = canonical_body_value([body, return_expression])
Digest::SHA256.hexdigest(JSON.generate(payload))
end
|
.canonical_body_value(value) ⇒ Object
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
|
# File 'lib/mxrb/dsl/builder.rb', line 1582
def self.canonical_body_value(value)
case value
when Hash
value.keys.sort_by(&:to_s).to_h do |key|
[key.to_s, canonical_body_value(value[key])]
end
when Array
value.map { canonical_body_value(_1) }
when Symbol
{ "__symbol__" => value.to_s }
else
value
end
end
|
Instance Method Details
#allow_concurrent_execution(value = true) ⇒ Object
1540
|
# File 'lib/mxrb/dsl/builder.rb', line 1540
def allow_concurrent_execution(value = true) = (@allow_concurrent_execution = !!value)
|
#allowed_roles(*roles) ⇒ Object
1544
1545
1546
|
# File 'lib/mxrb/dsl/builder.rb', line 1544
def allowed_roles(*roles)
@allowed_roles = roles.map(&:to_s)
end
|
#body_fingerprint(value) ⇒ Object
1573
1574
1575
|
# File 'lib/mxrb/dsl/builder.rb', line 1573
def body_fingerprint(value)
@expected_body_fingerprint = value.to_s
end
|
#bson_binary(base64, subtype: :generic) ⇒ Object
1534
1535
1536
|
# File 'lib/mxrb/dsl/builder.rb', line 1534
def bson_binary(base64, subtype: :generic)
BSON::Binary.new(Base64.strict_decode64(base64), subtype.to_sym)
end
|
#call(microflow: nil, nanoflow: nil) ⇒ Object
1548
1549
1550
1551
1552
|
# File 'lib/mxrb/dsl/builder.rb', line 1548
def call(microflow: nil, nanoflow: nil)
choices = { microflow: microflow, nanoflow: nanoflow }.compact
raise ArgumentError, "call requires exactly one target" unless choices.size == 1
@calls << { kind: choices.keys.first, name: choices.values.first.to_s }
end
|
#documentation(d) ⇒ Object
1539
|
# File 'lib/mxrb/dsl/builder.rb', line 1539
def documentation(d) = (@doc = d)
|
#excluded(value = true) ⇒ Object
1542
|
# File 'lib/mxrb/dsl/builder.rb', line 1542
def excluded(value = true) = (@excluded = !!value)
|
#mark_as_used(value = true) ⇒ Object
1541
|
# File 'lib/mxrb/dsl/builder.rb', line 1541
def mark_as_used(value = true) = (@mark_as_used = !!value)
|
#parameter(name, type:) ⇒ Object
1530
1531
1532
|
# File 'lib/mxrb/dsl/builder.rb', line 1530
def parameter(name, type:)
@parameters << { name: name.to_s, type: type.is_a?(Hash) ? type : type.to_s }
end
|
#rescue_all(&block) ⇒ Object
1558
1559
1560
1561
1562
|
# File 'lib/mxrb/dsl/builder.rb', line 1558
def rescue_all(&block)
rb = RescueBuilder.new
rb.instance_eval(&block) if block
_acts << { type: :rescue_all, activities: rb.activities }
end
|
#return_type(t) ⇒ Object
1538
|
# File 'lib/mxrb/dsl/builder.rb', line 1538
def return_type(t) = (@return_type = t.to_s)
|
#return_value(var) ⇒ Object
1564
1565
1566
1567
1568
1569
1570
1571
|
# File 'lib/mxrb/dsl/builder.rb', line 1564
def return_value(var)
if var.is_a?(Symbol)
@return_variable_name = var.to_s
@return_expression = "$#{var}"
else
@return_expression = var.to_s
end
end
|
#to_h ⇒ Object
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
|
# File 'lib/mxrb/dsl/builder.rb', line 1597
def to_h
current_fingerprint = self.class.body_digest(@body, @return_expression)
{
name: @name, runtime: @runtime, kind: @kind, public: @public,
parameters: @parameters, return_type: @return_type, documentation: @doc,
calls: @calls, repositories: @repositories, allowed_roles: @allowed_roles,
body: @body, return_variable_name: @return_variable_name,
return_expression: @return_expression,
allow_concurrent_execution: @allow_concurrent_execution,
mark_as_used: @mark_as_used, excluded: @excluded,
preserve_native_body: !@expected_body_fingerprint.nil? &&
@expected_body_fingerprint == current_fingerprint
}
end
|
#uses_repository(name) ⇒ Object
1554
1555
1556
|
# File 'lib/mxrb/dsl/builder.rb', line 1554
def uses_repository(name)
@repositories << name.to_s
end
|