Class: Pancake::PancakeConfig

Inherits:
Configuration::Base show all
Defined in:
lib/pancake/defaults/configuration.rb

Instance Method Summary collapse

Methods inherited from Configuration::Base

default, #defaults, description_for, #description_for, #singleton_class, #values

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Pancake::Configuration::Base

Instance Method Details

#_log_streamObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/pancake/defaults/configuration.rb', line 9

def _log_stream
  if Pancake.configuration.log_to_file
    log_dir = File.expand_path(File.join(Pancake.root, File.dirname(log_path)))
    FileUtils.mkdir_p(log_dir)
    log = File.join(log_dir, File.basename(log_path))
    File.open(log, (File::WRONLY | File::APPEND | File::CREAT))
  else
    STDOUT
  end
end

#configs(label = nil) {|result| ... } ⇒ Object

Yields:

  • (result)


31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pancake/defaults/configuration.rb', line 31

def configs(label = nil)
  @configs ||= Hash.new do |h,k|
    if (k.is_a?(Class) || k.is_a?(Module)) && defined?(k::Configuration)
      h[k] = k::Configuration.new
    else
      nil
    end
  end
  result = label.nil? ? @configs : @configs[label]
  yield result if block_given?
  result
end

#reset_log_stream!Object



20
21
22
# File 'lib/pancake/defaults/configuration.rb', line 20

def reset_log_stream!
  values.delete(:log_stream)
end

#stacks(label = nil) {|result| ... } ⇒ Object

Yields:

  • (result)


24
25
26
27
28
29
# File 'lib/pancake/defaults/configuration.rb', line 24

def stacks(label = nil)
  @stacks ||=  {}
  result = label.nil? ? @stacks : @stacks[label]
  yield result if block_given?
  result
end