Sha256: c316200bae6acac83548ecfa2bba6024c55dce40c8c4b71123691d8eea4c096f

Contents?: true

Size: 1.16 KB

Versions: 20

Compression:

Stored size: 1.16 KB

Contents

module WorkflowRESTHelpers
  attr_accessor :workflow_resources

  def self.workflow_resources
    @@workflow_resources ||= [Rbbt.share.views.find(:lib)]
  end

  def workflow_resources
    [Rbbt.www.views.find(:lib)] + WorkflowRESTHelpers.workflow_resources
  end

  def locate_workflow_template_from_resource(resource, template, workflow = nil, task = nil)
    template += '.haml' unless template =~ /.+\..+/

    paths = []
    paths << resource[workflow][task][template] if task and workflow
    paths << resource[workflow][template] if workflow
    paths << resource[template]

    paths.each do |path|
      return path.find if path.exists?
    end 

    nil
  end   

  def locate_workflow_template(template, workflow = nil, task = nil)

    if workflow
      path = locate_workflow_template_from_resource(workflow.libdir.www.views.find, template, workflow, task)
      return path if path and path.exists?
    end

    workflow_resources.each do |resource|
      path = locate_workflow_template_from_resource(resource, template, workflow, task)
      return path if path and path.exists?
    end

    raise "Template not found: [#{ template }, #{workflow}, #{ task }]"
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
rbbt-rest-1.8.44 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.43 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.42 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.41 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.40 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.38 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.37 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.36 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.35 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.34 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.32 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.31 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.30 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.29 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.28 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.27 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.26 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.25 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.23 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.22 lib/rbbt/rest/workflow/locate.rb