Module: Endeco

Defined in:
lib/endeco.rb,
lib/endeco/cache.rb,
lib/endeco/rails.rb,
lib/endeco/config.rb,
lib/endeco/version.rb

Defined Under Namespace

Modules: Cache, Config Classes: Railtie

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.[](key, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/endeco.rb', line 12

def self.[](key, options = {})
  safe_key = key.sub(/!$/, '')
  return Cache[safe_key] if Cache.enable and !options[:force] and Cache.key?(safe_key)
  fullpath = expand_path safe_key
  if File.exists? fullpath
    Cache[safe_key] = File.read fullpath
  else
    if key == safe_key
      nil
    else
      raise Errno::ENOENT, "Errno::ENOENT: No such file or directory - #{fullpath}"
    end
  end
end

.method_missing(symbol, *args) ⇒ Object



6
7
8
9
10
# File 'lib/endeco.rb', line 6

def self.method_missing(symbol, *args)
  safe_name = symbol.to_s.sub /!$/, ''
  def_methods safe_name
  __send__ symbol, *args
end