Sha256: 5fc05f1279521c6449130cc7493521fa5ae49f21eecfc086c44aa1e1f1be3c34
Contents?: true
Size: 565 Bytes
Versions: 44
Compression:
Stored size: 565 Bytes
Contents
module Lookbook class DataParser < Service def initialize(input, fail_silently: false, fallback: nil) @input = input @fail_silently = fail_silently @fallback = fallback end def call result = @input.present? ? parse(@input) : @fallback result.is_a?(Hash) ? result.deep_symbolize_keys : result rescue => exception @fail_silently ? @fallback : raise(exception) end protected def parse(input) raise ParserError.new "DataParser must be subclassed with a :parse method defined" end end end
Version data entries
44 entries across 44 versions & 1 rubygems