Skip to content

Commit c4e9aee

Browse files
committed
added rudimentary conditions support, renamed Resource#json to #to_hash
1 parent 456fd44 commit c4e9aee

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/esdb.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ def initialize(stats)
99
values = value.join(',')
1010
elsif value === true
1111
values = 'avg'
12+
elsif value.is_a?(Hash)
13+
values = value.collect{|calc, conds|
14+
if conds[0].is_a?(Array)
15+
conds.collect{|_conds| "#{calc}:[#{_conds.join(',')}]"}.join(',')
16+
else
17+
"#{calc}:[#{conds.join(',')}]"
18+
end
19+
}.join(',')
1220
else
1321
values = value
1422
end

lib/esdb/resource.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def get!(*args)
4040
@response = get(*args)
4141
end
4242

43-
def json
43+
def to_hash
4444
get! unless @response
4545
JSON.parse(@response)
4646
end

0 commit comments

Comments
 (0)