Sha256: 44ee479eeeaf7b9165416ab0cbfd10334978f43e564dd6c8f26873575a594408
Contents?: true
Size: 753 Bytes
Versions: 1
Compression:
Stored size: 753 Bytes
Contents
# frozen_string_literal: true require "date" require "erb" require "pathname" require "yaml" module Mihari module Services class AlertBuilder include Dry::Monads[:result, :try] # @return [String] attr_reader :path # # Initialize # # @param [String] path # def initialize(path) @path = path end # # @return [Hash] # def data raise ArgumentError, "#{path} does not exist" unless Pathname(path).exist? YAML.safe_load( ERB.new(File.read(path)).result, permitted_classes: [Date, Symbol] ) end def result Try[StandardError] { AlertProxy.new(**data) }.to_result end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mihari-5.6.2 | lib/mihari/services/alert_builder.rb |