Class/Module Index [+]

Quicksearch

Ruote::TemplateMixin

Template rendering helper.

(Currently only used by the SmtpParticipant, could prove useful for custom participants)

Public Instance Methods

render_default_template(workitem) click to toggle source

Simply returns a pretty-printed view of the workitem

# File lib/ruote/part/template.rb, line 53
def render_default_template (workitem)

  workitem = workitem.to_h if workitem.respond_to?(:to_h)

  s = []
  s << "workitem for #{workitem['participant_name']}"
  s << ''
  s << Rufus::Json.encode(workitem['fei'])
  s << ''
  workitem['fields'].keys.sort.each do |key|
    s << " - '#{key}'  ==>  #{Rufus::Json.encode(workitem['fields'][key])}"
  end
  s.join("\n")
end
render_template(template, flow_expression, workitem) click to toggle source
# File lib/ruote/part/template.rb, line 39
def render_template (template, flow_expression, workitem)

  template = (File.read(template) rescue nil) if is_a_file?(template)

  return render_default_template(workitem) unless template

  template = template.to_s
  workitem = workitem.to_h if workitem.respond_to?(:to_h)

  Ruote.dosub(template, flow_expression, workitem)
end

Protected Instance Methods

is_a_file?(s) click to toggle source
# File lib/ruote/part/template.rb, line 70
def is_a_file? (s)

  return false unless s
  return false if s.index("\n")

  File.exist?(s)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.