Class: FakeSNS::FileStorage

Inherits:
Storage
  • Object
show all
Defined in:
lib/fake_sns/storage.rb

Instance Method Summary collapse

Methods inherited from Storage

#[], #[]=, for, #initialize

Constructor Details

This class inherits a constructor from FakeSNS::Storage

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

#storageObject



57
58
59
# File 'lib/fake_sns/storage.rb', line 57

def storage
  @storage ||= YAML::Store.new(@database_filename)
end

#to_yamlObject



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

#transactionObject



61
62
63
64
65
# File 'lib/fake_sns/storage.rb', line 61

def transaction
  storage.transaction do
    yield
  end
end