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
38 39 40 41 42 |
# File 'lib/gitauth/saveable_class.rb', line 38 def add_item(item) load! if all.nil? all << item save! end |
.load! ⇒ Object
28 29 30 31 |
# File 'lib/gitauth/saveable_class.rb', line 28 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
33 34 35 36 |
# File 'lib/gitauth/saveable_class.rb', line 33 def save! load! if all.nil? File.open(store_path, "w+") { |f| f.write all.to_yaml } end |