module Matchd::Rule::Factory

Public Instance Methods

Rule(data) click to toggle source
# File lib/matchd/rule.rb, line 99
def Rule(data) # rubocop:disable Naming/MethodName
  return Rule::Invalid.new(data) unless data.is_a?(Hash)

  if data["respond"]
    Rule::Respond.new(data)
  elsif data["append_question"]
    Rule::Append.new(data)
  elsif data["passthrough"]
    Rule::Passthrough.new(data)
  elsif data["fail"]
    Rule::Fail.new(data)
  else
    Rule::Invalid.new(data)
  end
end