Sha256: e2b0a333836309035d0655d647a4a048058b3b8c04df3856b2d7e51503f91d08

Contents?: true

Size: 512 Bytes

Versions: 57

Compression:

Stored size: 512 Bytes

Contents

class ConfigStore
  attr_reader :file
  
  def initialize(file)
    @file = file
  end
  
  def load
    @config ||= YAML::load(open(file))
    self
  end
  
  def [](key)
    load
    @config[key]
  end
  
  def []=(key, value)
    @config[key] = value
  end
  
  def delete(*keys)
    keys.each { |key| @config.delete(key) }
    save
    self
  end
  
  def update(c={})
    @config.merge!(c)
    save
    self
  end
  
  def save
    File.open(file, 'w') { |f| f.write(YAML.dump(@config)) }
    self
  end
end

Version data entries

57 entries across 57 versions & 22 rubygems

Version Path
arthurgeek-twitter-0.6.15 examples/helpers/config_store.rb
bkocik-twitter-0.6.10 examples/helpers/config_store.rb
bkocik-twitter-0.6.8 examples/helpers/config_store.rb
bkocik-twitter-0.6.9 examples/helpers/config_store.rb
bkocik-twitter-0.7.0 examples/helpers/config_store.rb
cicloid-twitter-0.6.1 examples/helpers/config_store.rb
cicloid-twitter-0.6.2 examples/helpers/config_store.rb
codetocustomer-twitter-0.6.14 examples/helpers/config_store.rb
dacort-twitter-0.6.5 examples/helpers/config_store.rb
ddollar-twitter-0.6.15 examples/helpers/config_store.rb
ddollar-twitter-0.6.16 examples/helpers/config_store.rb
ddollar-twitter-0.6.17 examples/helpers/config_store.rb
ddollar-twitter-0.7.0 examples/helpers/config_store.rb
deadprogrammer-twitter-0.6.11 examples/helpers/config_store.rb
deadprogrammer-twitter-0.6.12 examples/helpers/config_store.rb
deadprogrammer-twitter-0.6.7 examples/helpers/config_store.rb
deedubs-twitter-0.7.0 examples/helpers/config_store.rb
deedubs-twitter-0.8.0 examples/helpers/config_store.rb
egze-twitter-0.6.13 examples/helpers/config_store.rb
erwaller-twitter-0.6.13.1 examples/helpers/config_store.rb