Sha256: 3b4193a3f4df0d537019ea5398b608619b467a139651afc2f57a99b2f7a6a9b5
Contents?: true
Size: 713 Bytes
Versions: 4
Compression:
Stored size: 713 Bytes
Contents
module Codily module Elements module FileLoadable def self.included(klass) klass.instance_eval do def def_file_loadable_attr(*attrs) attrs.each do |attr| define_method(attr) do |obj = nil| getset attr, file_loadable(obj) end end end end end private def file_loadable(obj) case obj when Hash if obj.key?(:inline) return obj[:inline] end if obj.key?(:file) return File.read(obj[:file]) end raise ArgumentError else return obj.to_s end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems