Class: ManageIQ::Floe::Workflow::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/manageiq/floe/workflow/path.rb

Direct Known Subclasses

ReferencePath

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Path

Returns a new instance of Path.



13
14
15
# File 'lib/manageiq/floe/workflow/path.rb', line 13

def initialize(payload)
  @payload = payload
end

Class Method Details

.value(payload, context, input = {}) ⇒ Object



8
9
10
# File 'lib/manageiq/floe/workflow/path.rb', line 8

def value(payload, context, input = {})
  new(payload).value(context, input)
end

Instance Method Details

#value(context, input = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/manageiq/floe/workflow/path.rb', line 17

def value(context, input = {})
  obj, path =
    if payload.start_with?("$$")
      [context, payload[1..]]
    else
      [input, payload]
    end

  results = JsonPath.on(obj, path)

  results.count < 2 ? results.first : results
end