Class: GitAuth::BasicSaveable
- Inherits:
-
Object
- Object
- GitAuth::BasicSaveable
- Defined in:
- lib/gitauth/saveable_class.rb
Class Method Summary collapse
Class Method Details
.add_item(item) ⇒ Object
37 38 39 40 41 |
# File 'lib/gitauth/saveable_class.rb', line 37 def add_item(item) load! if all.nil? all << item save! end |
.load! ⇒ Object
27 28 29 30 |
# File 'lib/gitauth/saveable_class.rb', line 27 def load! self.all = YAML.load(File.read(store_path)) rescue nil if File.file?(store_path) self.all = [] unless all.is_a?(Array) end |
.save! ⇒ Object
32 33 34 35 |
# File 'lib/gitauth/saveable_class.rb', line 32 def save! load! if all.nil? File.open(store_path, "w+") { |f| f.write all.to_yaml } end |