Module: Chicanery::Persistence
- Included in:
- Chicanery
- Defined in:
- lib/chicanery/persistence.rb
Instance Method Summary collapse
Instance Method Details
#persist(state) ⇒ Object
5 6 7 8 9 |
# File 'lib/chicanery/persistence.rb', line 5 def persist state File.open persist_state_to, 'w' do |file| file.puts state.to_yaml end end |
#persist_state_to(path = nil) ⇒ Object
16 17 18 19 |
# File 'lib/chicanery/persistence.rb', line 16 def persist_state_to path=nil @state = path if path @state || 'state' end |
#restore ⇒ Object
11 12 13 14 |
# File 'lib/chicanery/persistence.rb', line 11 def restore return {} unless File.exist? persist_state_to YAML.load_file persist_state_to end |