Organized

This commit is contained in:
Gregory Eremin
2013-07-09 14:53:49 +07:00
parent 409d3f26e2
commit ab5072c1c5
9 changed files with 76 additions and 33 deletions
+3
View File
@@ -0,0 +1,3 @@
CONFIG = {
database_url: 'postgres://pastemaster:pastemaster@localhost:5432/pastemaster'
}
+8
View File
@@ -0,0 +1,8 @@
DB = Sequel.connect(CONFIG[:database_url])
DB.create_table(:pastes) do
primary_key :id
String :handle
String :type
Text :contents
end unless DB.table_exists?(:pastes)
+20
View File
@@ -0,0 +1,20 @@
module Paste
def get(params)
table.where(params).first
end
def add(params)
id = table.insert(params)
return unless id.is_a?(Integer)
get(id: id)
end
private
def table
DB[:pastes]
end
extend self
end