Class: ICouchbase::Handler

Inherits:
DSL
  • Object
show all
Defined in:
lib/icouchbase/handler.rb

Instance Attribute Summary

Attributes inherited from DSL

#db

Instance Method Summary collapse

Methods inherited from DSL

command, commands, #initialize, #normalize!, #parse

Constructor Details

This class inherits a constructor from ICouchbase::DSL

Instance Method Details

#exec(input) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/icouchbase/handler.rb', line 33

def exec(input)
  block, *args = parse(input)
  r = instance_exec(*args, &block)
  ret = []
  ret << "CAS:   #{r[:cas]}" if r[:cas]
  ret << "FLAGS: #{r[:flags]}" if r[:flags]
  ret << r[:value] if r[:value]
  ret.join("\n")
rescue ParseError => e
  "ERROR: #{e.message}"
rescue Couchbase::Error::Base => e
  "ERROR: #{e.message}"
end