Class: Ro::Config

Inherits:
Map show all
Defined in:
lib/ro/config.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, **kws) ⇒ Config

Returns a new instance of Config.



34
35
36
37
38
39
40
41
42
# File 'lib/ro/config.rb', line 34

def initialize(*args, **kws)
  configure!(Config.defaults)

  args.each do |arg|
    configure!(arg) if arg.is_a?(Hash)
  end

  configure!(kws)
end

Class Method Details

.defaultsObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ro/config.rb', line 3

def Config.defaults
  {
    :root =>
      (Ro.env.root || Ro.defaults.root),

    :build =>
      (Ro.env.build || Ro.defaults.build),

    :url =>
      (Ro.env.url || Ro.defaults.url),

    :img_url =>
      (Ro.env.img_url || Ro.defaults.img_url),

    :page_size =>
      (Ro.env.page_size || Ro.defaults.page_size),

    :log =>
      (Ro.env.log || Ro.defaults.log),

    :debug =>
      (Ro.env.debug || Ro.defaults.debug),

    :port =>
      (Ro.env.port || Ro.defaults.port),

    :md_theme =>
      (Ro.env.md_theme || Ro.defaults.md_theme),
  }
end

Instance Method Details

#configure!(hash) ⇒ Object



44
45
46
47
48
# File 'lib/ro/config.rb', line 44

def configure!(hash)
  hash.each do |key, value|
    send("#{ key }=", value)
  end
end