Class: Boomloop::Authentication::Store::YAMLStore
- Defined in:
- lib/boomloop/authentication/store/yaml_store.rb
Instance Method Summary collapse
- #find(user) ⇒ Object
-
#initialize(filename = "#{ ENV["HOME"] }/.boomloop_credentials.yml") ⇒ YAMLStore
constructor
pass in where the yml should be stored.
- #load_config ⇒ Object
- #save_config ⇒ Object
- #update(credentials) ⇒ Object
Constructor Details
#initialize(filename = "#{ ENV["HOME"] }/.boomloop_credentials.yml") ⇒ YAMLStore
pass in where the yml should be stored.
10 11 12 13 |
# File 'lib/boomloop/authentication/store/yaml_store.rb', line 10 def initialize(filename = "#{ ENV["HOME"] }/.boomloop_credentials.yml") @config_filename = filename self.load_config end |
Instance Method Details
#find(user) ⇒ Object
35 36 37 |
# File 'lib/boomloop/authentication/store/yaml_store.rb', line 35 def find(user) ::Boomloop::Authentication::Credentials.new(user, self, @config[user]) end |
#load_config ⇒ Object
15 16 17 18 19 20 |
# File 'lib/boomloop/authentication/store/yaml_store.rb', line 15 def load_config file = File.new(@config_filename, "a+") file.rewind @config = YAML.load(file) || {} file.close end |
#save_config ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/boomloop/authentication/store/yaml_store.rb', line 22 def save_config if @config File.open(@config_filename, "w") do |f| f.write @config.to_yaml end end end |
#update(credentials) ⇒ Object
30 31 32 33 |
# File 'lib/boomloop/authentication/store/yaml_store.rb', line 30 def update(credentials) @config[credentials.username] = credentials. self.save_config end |