Class: Flor::Macro::Schedule

Inherits:
Flor::Macro show all
Defined in:
lib/flor/punit/schedule.rb

Direct Known Subclasses

Pro::Cron, Pro::Every

Constant Summary

Constants inherited from Procedure

Procedure::RVARS, Procedure::TRUE_ATTS

Instance Attribute Summary

Attributes inherited from Node

#message

Instance Method Summary collapse

Methods inherited from Flor::Macro

#rewrite

Methods inherited from Procedure

[], core?, #debug_msg, #debug_tree, #end, #flank, #heap, inherited, make, names, #pre_execute, #prepare_on_receive_last, #trigger_on_error

Methods inherited from Node

#child_id, #cnodes, #cnodes_any?, #cnodes_empty?, #deref, #descendant_of?, #domain, #exid, #fei, #from, #h, #initialize, #lookup_tree, #lookup_value, #message_or_node_payload, #nid, #node_closed?, #node_ended?, #node_open?, #node_payload, #node_payload_ret, #node_status, #node_status_flavour, #on_error_parent, #parent, #payload, #payload_ret, #point, #reheap, #to_procedure_node, #tree

Constructor Details

This class inherits a constructor from Flor::Node

Instance Method Details

#rewrite_schedule_tree(schedule_type) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/flor/punit/schedule.rb', line 95

def rewrite_schedule_tree(schedule_type)

  atts = att_children
  schedule_i = atts.index { |at| at[1].size == 1 }

  fail Flor::FlorError.new("schedule not found in #{tree.inspect}", self) \
    unless schedule_i

  schedule =
    schedule_type ?
    Flor.dup(atts.delete_at(schedule_i)[1][0]) :
    nil

  l = tree[2]

  th = [ 'schedule', [], l, *tree[3] ]
  th[1] << [ '_att', [ [ schedule_type, [], l ], schedule ], l ] if schedule
  atts.each { |ac| th[1] << Flor.dup(ac) }

  td = [ 'def', [], l ]
  td[1] << [ '_att', [ [ 'msg', [], l ] ], l ]
  non_att_children.each { |nac| td[1] << Flor.dup(nac) }

  th[1] << td

  th
end