Sha256: 0722f880e6db67697d7dc90fec6a533e5173ef7389597a9414cacf9a5e16a44d

Contents?: true

Size: 1.16 KB

Versions: 166

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

166 entries across 166 versions & 1 rubygems

Version Path
rbbt-rest-1.8.21 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.20 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.19 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.18 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.17 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.16 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.15 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.14 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.13 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.12 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.11 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.10 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.9 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.8 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.7 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.6 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.5 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.4 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.3 lib/rbbt/rest/workflow/locate.rb
rbbt-rest-1.8.2 lib/rbbt/rest/workflow/locate.rb