Sha256: ca91b496029aff1bf2c825dd86ac82cbedfcca15a1f89ff8084aacbf26910fe1

Contents?: true

Size: 1.04 KB

Versions: 209

Compression:

Stored size: 1.04 KB

Contents

module KnowledgeBaseRESTHelpers

  def self.association_resources
    @association_resources ||= []
  end

  def association_resources
    [Rbbt.share.views.find(:lib)] +  KnowledgeBaseRESTHelpers.association_resources
  end

  def locate_association_template_from_resource(resource, database = nil)
    if database == "Default" 
      path = resource.association["Default.haml"]
      if path.exists?
        return path
      else
        return nil
      end
    end

    path = resource.association[database + '.haml']
    return path if path.exists?

    nil
  end   

  def locate_association_template(database)

    association_resources.each do |resource|
      path = locate_association_template_from_resource(resource, database)
      return path if path and path.exists?
    end

    association_resources.each do |resource|
      path = locate_association_template_from_resource(resource, "Default")
      return path if path and path.exists?
    end

    raise "Template not found for association database: #{ Misc.fingerprint database }"
  end
end

Version data entries

209 entries across 209 versions & 1 rubygems

Version Path
rbbt-rest-1.8.136 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.135 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.134 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.133 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.132 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.131 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.130 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.129 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.126 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.123 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.122 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.121 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.120 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.119 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.118 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.117 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.116 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.115 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.114 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.113 lib/rbbt/rest/knowledge_base/locate.rb