Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasc committed Sep 2, 2014
1 parent 993e811 commit 20fdf4f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/dragonfly/moped_data_store.rb
Expand Up @@ -25,6 +25,14 @@ def initialize opts={}
@db = opts[:db]
end

def session
@session ||= Moped::Session.new(["#{@host}:#{@port}"]).tap do |session|
session.use @db
end
end

# ---------------------------------------------------------------------

def write temp_object, opts={}
content_type = opts[:content_type] || opts[:mime_type] || 'application/octet-stream'
meta = temp_object.meta
Expand All @@ -39,12 +47,6 @@ def write temp_object, opts={}

# ---------------------------------------------------------------------

def session
@session ||= Moped::Session.new(["#{@host}:#{@port}"]).tap do |session|
session.use @db
end
end

def read uid
grid_file = session.bucket.open(uid, 'r')
meta = grid_file.metadata.each_with_object({}){ |(k,v), h| h[k.to_sym] = v }
Expand All @@ -65,4 +67,4 @@ def destroy uid
end
end

Dragonfly::App.register_datastore(:moped){ Dragonfly::MopedDataStore }
Dragonfly::App.register_datastore(:moped){ Dragonfly::MopedDataStore }

0 comments on commit 20fdf4f

Please sign in to comment.