Method: AASMExport#transition_code

Defined in:
lib/lucidMachines/aasm_export.rb

#transition_code(event, inputs, output) ⇒ Object



281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/lucidMachines/aasm_export.rb', line 281

def transition_code(event, inputs, output)
  
  code = "        transitions :from => "
  if inputs.size == 1
    code = code + ":" + sanitize(inputs[0].text)
  else
    code = code + "["
    inputs.each do |input|
      code = code + ":" + sanitize(input.text) + ","
    end
    ## remove last "," 
    code = code.chop + "]"
  end

  code = code + ", :to => :" + sanitize(output.text)
  ## TODO: add options

  # TransitionCallbacks
  ## Add event :before  :after...  METHOD out of this
  ## Not yet testable
  #  callback_code = generate_callback(event, "method", TransitionCallbacks)
  callback_code = ""
  
  return code + callback_code
end