Class: Copy::Storage::Relational
- Inherits:
-
Object
- Object
- Copy::Storage::Relational
- Defined in:
- lib/copy/storage/relational.rb
Defined Under Namespace
Classes: Document
Instance Method Summary collapse
- #get(name) ⇒ Object
-
#initialize(connection_url) ⇒ Relational
constructor
A new instance of Relational.
- #set(name, content) ⇒ Object
Constructor Details
#initialize(connection_url) ⇒ Relational
14 15 16 17 18 |
# File 'lib/copy/storage/relational.rb', line 14 def initialize(connection_url) DataMapper.setup(:default, connection_url) DataMapper.finalize DataMapper.auto_upgrade! end |
Instance Method Details
#get(name) ⇒ Object
20 21 22 23 |
# File 'lib/copy/storage/relational.rb', line 20 def get(name) doc = Document.first(:name => name) doc.content unless doc.nil? end |
#set(name, content) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/copy/storage/relational.rb', line 25 def set(name, content) doc = Document.first(:name => name) if doc doc.update(:content => content) else Document.create(:name => name, :content => content) end end |