class Alephant::Support::Parser

Attributes

vary_lookup[R]

Public Class Methods

new(vary_jsonpath = nil) click to toggle source
# File lib/alephant/support/parser.rb, line 9
def initialize(vary_jsonpath = nil)
  @vary_lookup = vary_jsonpath ? JsonPathLookup.new(vary_jsonpath) : nil
end

Public Instance Methods

parse(msg) click to toggle source
# File lib/alephant/support/parser.rb, line 13
def parse(msg)
  symbolize(msg.body).tap { |o| o[:options] = options_for msg unless not o[:options].nil? }
end

Private Instance Methods

options_for(msg) click to toggle source
# File lib/alephant/support/parser.rb, line 22
def options_for(msg)
  {}.tap do |o|
    o[:variant] = vary_lookup.lookup(msg.body) if not vary_lookup.nil?
  end
end
symbolize(data) click to toggle source
# File lib/alephant/support/parser.rb, line 18
def symbolize(data)
  JSON.parse(data, :symbolize_names => true)
end