Sha256: 015231f686b5c2d60489029d8f2eb85008b8ffc447c3f2e59033b73cf44f003a
Contents?: true
Size: 787 Bytes
Versions: 18
Compression:
Stored size: 787 Bytes
Contents
require 'pathname' module Determinator module Retrieve # A class which loads features from files within the initialized folder class File # @param :root [String,Pathname] The path to be used as the root to look in # @param :serializer [#load] A serializer which will take the string of the read file and return a Feature object. def initialize(root:, serializer: Determinator::Serializers::JSON ) @root = Pathname.new(root) @serializer = serializer end def retrieve(feature_id) feature = @root.join(feature_id.to_s) return MissingResponse.new unless feature.exist? @serializer.load(feature.read) rescue => e Determinator.notice_error(e) ErrorResponse.new end end end end
Version data entries
18 entries across 18 versions & 1 rubygems