Class: FacebookTestUsers::DB
- Inherits:
-
Object
- Object
- FacebookTestUsers::DB
- Defined in:
- lib/facebook_test_users/db.rb
Overview
This is about the dumbest DB you can get. It’s a hash that knows how to serialize itself. Dumb, but it gets the job done.
Class Method Summary collapse
Class Method Details
.[](arg) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/facebook_test_users/db.rb', line 10 def [](arg) # FIXME deep-freeze this; shallow freezing is insufficient result = yaml[arg] result.freeze result end |
.filename ⇒ Object
27 28 29 |
# File 'lib/facebook_test_users/db.rb', line 27 def filename @filename || File.join(ENV['HOME'], '.fbturc') end |
.filename=(f) ⇒ Object
31 32 33 34 |
# File 'lib/facebook_test_users/db.rb', line 31 def filename=(f) @cached_yaml = nil @filename = f end |
.update {|data| ... } ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/facebook_test_users/db.rb', line 17 def update @cached_yaml = nil data = _yaml yield data # do this *before* blowing away the db data_as_yaml = data.to_yaml File.open(filename, 'w') { |f| f.write(data_as_yaml) } end |