Skip to content

Commit 558a0aa

Browse files
committed
added Replay.upload base
1 parent 004c731 commit 558a0aa

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/esdb/replay.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
module ESDB
22
class Replay < ESDB::Resource
3+
# POSTs a given replay file to esdb and returns the job ID if it was
4+
# successfully queued for processing.
5+
def self.upload(file)
6+
replay = self.new
7+
response = JSON.parse(RestClient.post(replay.url, :file => file))
8+
Rails.logger.info response.inspect
9+
10+
response['job'] ? response['job'] : false
11+
end
312
end
413
end

lib/esdb/resource.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def initialize(url=nil, options={}, *args)
2020
# For now, various params will trigger a change in the URI
2121
# might want to do it more like Rails in esdb ..not sure yet
2222
@params = options[:headers][:params]
23-
if @params.any?
23+
if @params && @params.any?
2424
@url += "/#{@params.delete(:id)}" if @params[:id]
2525
options[:headers][:params][:stats] = StatsParam.new(options[:headers][:params][:stats]) if @params[:stats]
2626
end
@@ -40,6 +40,12 @@ def get!(*args)
4040
@response = get(*args)
4141
end
4242

43+
def self.from_hash(hash)
44+
resource = self.new
45+
resource.response = hash
46+
resource
47+
end
48+
4349
def to_hash
4450
get! unless @response
4551
JSON.parse(@response)

0 commit comments

Comments
 (0)