Class: XRBP::ResultParserBase

Inherits:
PluginBase show all
Defined in:
lib/xrbp/plugins/result_parser.rb

Overview

Result Parser plugin base class, allows request results to be converted before returning / invoking callback.

Instance Attribute Summary collapse

Attributes inherited from PluginBase

#connection

Instance Method Summary collapse

Methods inherited from PluginBase

#initialize

Constructor Details

This class inherits a constructor from XRBP::PluginBase

Instance Attribute Details

#parserObject

Returns the value of attribute parser.



5
6
7
# File 'lib/xrbp/plugins/result_parser.rb', line 5

def parser
  @parser
end

Instance Method Details

#addedObject



7
8
9
10
11
12
# File 'lib/xrbp/plugins/result_parser.rb', line 7

def added
  plugin = self
  connection.define_instance_method(:parse_results) do |&bl|
    plugin.parser = bl
  end
end

#parse_result(res, req) ⇒ Object



14
15
16
17
# File 'lib/xrbp/plugins/result_parser.rb', line 14

def parse_result(res, req)
  return res unless parser
  parser.call(res, req)
end