Class: FakeSNS::FileStorage
Instance Method Summary
collapse
Methods inherited from Storage
#[], #[]=, for, #initialize
Instance Method Details
#replace(data) ⇒ Object
67
68
69
70
71
|
# File 'lib/fake_sns/storage.rb', line 67
def replace(data)
File.open(@database_filename, "w:utf-8") do |f|
f.write(data)
end
end
|
#storage ⇒ Object
57
58
59
|
# File 'lib/fake_sns/storage.rb', line 57
def storage
@storage ||= YAML::Store.new(@database_filename)
end
|
#to_yaml ⇒ Object
52
53
54
55
|
# File 'lib/fake_sns/storage.rb', line 52
def to_yaml
storage["x"]
storage.instance_variable_get(:@table).to_yaml
end
|
#transaction ⇒ Object
61
62
63
64
65
|
# File 'lib/fake_sns/storage.rb', line 61
def transaction
storage.transaction do
yield
end
end
|