Class: Promiscuous::Publisher::Operation::ProxyForQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/promiscuous/publisher/operation/proxy_for_query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operation, &block) ⇒ ProxyForQuery

Returns a new instance of ProxyForQuery.



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/promiscuous/publisher/operation/proxy_for_query.rb', line 4

def initialize(operation, &block)
  @operation = operation
  @queries = {}

  if block.arity == 1
    block.call(self)
  else
    self.non_instrumented { block.call }
    self.instrumented { block.call }
  end
end

Instance Attribute Details

#exceptionObject

Returns the value of attribute exception.



2
3
4
# File 'lib/promiscuous/publisher/operation/proxy_for_query.rb', line 2

def exception
  @exception
end

#resultObject

Returns the value of attribute result.



2
3
4
# File 'lib/promiscuous/publisher/operation/proxy_for_query.rb', line 2

def result
  @result
end

Instance Method Details

#call_and_remember_result(which) ⇒ Object



28
29
30
31
32
33
# File 'lib/promiscuous/publisher/operation/proxy_for_query.rb', line 28

def call_and_remember_result(which)
  raise "Fatal: #{which} query unspecified" unless @queries[which]
  @result = @queries[which].call(@operation)
rescue Exception => e
  @exception = e
end

#failed?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/promiscuous/publisher/operation/proxy_for_query.rb', line 35

def failed?
  !!@exception
end

#instrumented(&block) ⇒ Object



24
25
26
# File 'lib/promiscuous/publisher/operation/proxy_for_query.rb', line 24

def instrumented(&block)
  @queries[:instrumented] = block
end

#non_instrumented(&block) ⇒ Object



20
21
22
# File 'lib/promiscuous/publisher/operation/proxy_for_query.rb', line 20

def non_instrumented(&block)
  @queries[:non_instrumented] = block
end

#prepare(&block) ⇒ Object



16
17
18
# File 'lib/promiscuous/publisher/operation/proxy_for_query.rb', line 16

def prepare(&block)
  @queries[:prepare] = block
end