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.9.1 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.9.0 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.157 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.156 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.155 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.154 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.152 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.151 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.150 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.148 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.147 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.146 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.145 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.144 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.143 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.142 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.140 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.139 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.138 lib/rbbt/rest/knowledge_base/locate.rb
rbbt-rest-1.8.137 lib/rbbt/rest/knowledge_base/locate.rb