class Blackbriar::ValueProvider

Attributes

data[R]

Public Class Methods

new(data) click to toggle source
# File lib/blackbriar/value_provider.rb, line 12
def initialize(data)
  @data = data.deep_stringify_keys
end

Public Instance Methods

resolve(arg) click to toggle source
# File lib/blackbriar/value_provider.rb, line 16
def resolve(arg)
  path = is_json_path?(arg.to_s) ? arg.to_s.split(":").last : nil
  return arg unless path
  JsonPath.on(data, path).first
end

Private Instance Methods

is_json_path?(method_name) click to toggle source
# File lib/blackbriar/value_provider.rb, line 25
def is_json_path?(method_name)
  # Ensure that we are dealin with a json path object
  /^json_path/.match(method_name)
end