Sha256: faa17c9f5aa45ec5c25eb6ba29b1353898f2bf8721b444b74e121a613ba2a709
Contents?: true
Size: 751 Bytes
Versions: 9
Compression:
Stored size: 751 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
9 entries across 9 versions & 1 rubygems