Sha256: 15fd9bc914fac6cd6c87588ee81471165b2a00d6df642c895c6cce32d4cd1136
Contents?: true
Size: 912 Bytes
Versions: 18
Compression:
Stored size: 912 Bytes
Contents
# coding: utf-8 # frozen_string_literal: true module Stealth class ServiceReply attr_accessor :recipient_id, :replies, :yaml_reply, :context def initialize(recipient_id:, yaml_reply:, context:, preprocessor: :none) @recipient_id = recipient_id @yaml_reply = yaml_reply @context = context processed_reply = case preprocessor when :erb preprocess_erb when :none @yaml_reply end @replies = load_replies(YAML.load(processed_reply)) end private def load_replies(unstructured_replies) unstructured_replies.collect do |reply| Stealth::Reply.new(unstructured_reply: reply) end end def preprocess_erb begin ERB.new(yaml_reply).result(context) rescue NameError => e raise(Stealth::Errors::UndefinedVariable, e.message) end end end end
Version data entries
18 entries across 18 versions & 1 rubygems