Sha256: 3b12a81085ff793e720ada2ae736c8231c862fa167168831eda70e09755f20c1
Contents?: true
Size: 699 Bytes
Versions: 5
Compression:
Stored size: 699 Bytes
Contents
require 'hanami/utils/kernel' module Hanami module Config # Block or file mapper # # @since 0.1.0 # @api private class Mapper EXTNAME = '.rb' def initialize(root, path, &blk) @path, @blk = path, blk @path = root.join(path) if root && path end def to_proc return @blk if @blk code = realpath.read Proc.new { eval(code) } end private def realpath Utils::Kernel.Pathname("#{ @path }#{ EXTNAME }").realpath rescue Errno::ENOENT raise ArgumentError, error_message end def error_message 'You must specify a block or a file.' end end end end
Version data entries
5 entries across 5 versions & 1 rubygems