Class: Ruml::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Config

Returns a new instance of Config.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ruml/config.rb', line 7

def initialize(path)
  @path = path.to_s

  case @path
  when /\.ya?ml/
    construct Moneta::Adapters::YAML, :file => @path
  else
    raise ArgumentError, "Couldn't find mailing list in #{@path.inspect}" unless File.directory?(@path)
    construct Moneta::Adapters::File, :dir => @path
  end
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#[](name) ⇒ Object



19
20
21
# File 'lib/ruml/config.rb', line 19

def [](name)
  @moneta[name]
end

#[]=(name, value) ⇒ Object



23
24
25
# File 'lib/ruml/config.rb', line 23

def []=(name, value)
  @moneta[name] = value
end

#construct(adapter, *args) ⇒ Object



27
28
29
30
31
# File 'lib/ruml/config.rb', line 27

def construct(adapter, *args)
  @moneta = Moneta.build do
    use adapter, *args
  end
end