Module: GermDefault

Included in:
Fasta, GO::Annotation, GO::Ontology, GTF
Defined in:
lib/germ/config.rb

Constant Summary collapse

CACHE =
{}

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/germ/config.rb', line 64

def method_missing sym, *args, &block
  begin
    cache_load sym
  rescue GermConfig::KeyError
    # the key does not exist, try to pass it on
    super
  end
end

Instance Method Details

#cacheObject



50
51
52
# File 'lib/germ/config.rb', line 50

def cache
  CACHE[self] ||= {}
end

#cache_load(key) ⇒ Object



60
61
62
# File 'lib/germ/config.rb', line 60

def cache_load key
  cache[key] ||= load_key(key)
end

#defaultObject



54
55
56
57
# File 'lib/germ/config.rb', line 54

def default
  # get the default key
  cache[:default] ||= load_default
end

#has_default(*key_chain) ⇒ Object



46
47
48
# File 'lib/germ/config.rb', line 46

def has_default *key_chain
  @key_chain = key_chain
end