Class: Bookery::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/bookery/config.rb

Constant Summary collapse

META_METHODS =
[:title, :authors, :editors, :template]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(language, config) ⇒ Config

Returns a new instance of Config.



7
8
9
10
# File 'lib/bookery/config.rb', line 7

def initialize(language, config)
  @language = language
  @config = config.symbolize_keys
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bookery/config.rb', line 16

def method_missing(method, *args)
  if META_METHODS.include?(method)
    if value = lang_specific_value(method)
      value
    else
      config[method]
    end
  else
    super
  end
end

Instance Attribute Details

#languageObject (readonly)

Returns the value of attribute language.



5
6
7
# File 'lib/bookery/config.rb', line 5

def language
  @language
end

Instance Method Details

#[](key) ⇒ Object



12
13
14
# File 'lib/bookery/config.rb', line 12

def [](key)
  public_send(key)
end