Sha256: 4c0d546c9256a829ef68847258b400c42bf93b863d79eff579f6c11bd494e928

Contents?: true

Size: 644 Bytes

Versions: 15

Compression:

Stored size: 644 Bytes

Contents

# coding: utf-8
# frozen_string_literal: true

module Stealth
  class ServiceReply

    attr_accessor :recipient_id, :replies

    def initialize(recipient_id:, yaml_reply:, context:)
      @recipient_id = recipient_id

      begin
        erb_reply = ERB.new(yaml_reply).result(context)
      rescue NameError => e
        raise(Stealth::Errors::UndefinedVariable, e.message)
      end

      @replies = load_replies(YAML.load(erb_reply))
    end

    private

      def load_replies(unstructured_replies)
        unstructured_replies.collect do |reply|
          Stealth::Reply.new(unstructured_reply: reply)
        end
      end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
stealth-0.10.6 lib/stealth/service_reply.rb
stealth-0.10.5 lib/stealth/service_reply.rb
stealth-0.10.4 lib/stealth/service_reply.rb
stealth-0.10.3 lib/stealth/service_reply.rb
stealth-0.10.2 lib/stealth/service_reply.rb
stealth-0.10.1 lib/stealth/service_reply.rb
stealth-0.10.0 lib/stealth/service_reply.rb
stealth-0.9.8 lib/stealth/service_reply.rb
stealth-0.9.7 lib/stealth/service_reply.rb
stealth-0.9.6 lib/stealth/service_reply.rb
stealth-0.9.5 lib/stealth/service_reply.rb
stealth-0.9.4 lib/stealth/service_reply.rb
stealth-0.9.3 lib/stealth/service_reply.rb
stealth-0.9.2 lib/stealth/service_reply.rb
stealth-0.9.1 lib/stealth/service_reply.rb