Class: Alephant::Support::JsonPathLookup

Inherits:
Object
  • Object
show all
Defined in:
lib/alephant/support/jsonpath_lookup.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ JsonPathLookup

Returns a new instance of JsonPathLookup.



8
9
10
11
# File 'lib/alephant/support/jsonpath_lookup.rb', line 8

def initialize(path)
  @path = path
  @jsonpath = JsonPath.new(path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/alephant/support/jsonpath_lookup.rb', line 7

def path
  @path
end

Instance Method Details

#lookup(msg) ⇒ Object



13
14
15
# File 'lib/alephant/support/jsonpath_lookup.rb', line 13

def lookup(msg)
  @jsonpath.on(JSON.parse(msg)).first
end