Sha256: a8c6dbd6fcaf0d3ca29a18f6980201b88684c6aace98abd22b87c9145891462c
Contents?: true
Size: 978 Bytes
Versions: 13
Compression:
Stored size: 978 Bytes
Contents
require 'lotus/utils/kernel' module Lotus module Model module Config # Read mapping file for mapping DSL # # @since 0.2.0 # @api private class Mapper EXTNAME = '.rb' def initialize(path=nil, &blk) if block_given? @blk = blk elsif path @path = root.join(path) else raise Lotus::Model::InvalidMappingError.new('You must specify a block or a file.') end end def to_proc unless @blk code = realpath.read @blk = Proc.new { eval(code) } end @blk end private def realpath Utils::Kernel.Pathname("#{ @path }#{ EXTNAME }").realpath rescue Errno::ENOENT raise ArgumentError, 'You must specify a valid filepath.' end def root Utils::Kernel.Pathname(Dir.pwd).realpath end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems