Class: Brief::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/brief/configuration.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



35
36
37
38
39
40
41
42
43
# File 'lib/brief/configuration.rb', line 35

def method_missing(meth, *args, &block)
  if current.respond_to?(meth) && current.key?(meth)
    current.send(meth, *args, &block)
  else
    # swallow invalid method calls in production
    super if ENV['BRIEF_DEBUG_MODE']
    nil
  end
end

Class Method Details

.method_missing(meth, *args, &block) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/brief/configuration.rb', line 7

def self.method_missing(meth, *args, &block)
  if instance.respond_to?(meth)
    instance.send(meth, *args, &block)
  else
    super
  end
end

Instance Method Details

#currentObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/brief/configuration.rb', line 15

def current
  @current ||= {
    docs_path: 'docs',
    models_path: 'models',
    templates_path: 'templates',
    data_path: 'data',
    assets_path: 'assets',
    lib_path: "lib",

    # line wrapping in vim and other editors creates
    # a bunch of extra br/ tags
    preserve_gfm_line_breaks: false
  }.to_mash
end

#set(attribute, value = nil) ⇒ Object



30
31
32
33
# File 'lib/brief/configuration.rb', line 30

def set(attribute, value = nil)
  current[attribute] = value
  self
end