class Chef::OrgIdCache
Constants
- NO_ORG
Attributes
cache[RW]
db[RW]
Public Class Methods
new(db)
click to toggle source
# File lib/chef/org_id_cache.rb, line 24 def initialize(db) @db = db @cache = {} end
Public Instance Methods
fetch(org_name)
click to toggle source
# File lib/chef/org_id_cache.rb, line 29 def fetch(org_name) if cache.key?(org_name) && cache[org_name] != NO_ORG cache[org_name] elsif cache.key?(org_name) && cache[org_name] == NO_ORG nil else r = db.select(:id).from(:orgs).where(:name => org_name).first if r.nil? store(org_name, NO_ORG) nil else store(org_name, r[:id]) r[:id] end end end
store(org_name, org_guid)
click to toggle source
# File lib/chef/org_id_cache.rb, line 46 def store(org_name, org_guid) cache[org_name] = org_guid end