Sha256: e6897a60fbcf2b69b8df34c081fc7dd99e52edde0e2aa6fec27012a0ae6dd0e8
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module Tori class File def initialize(model, from: nil, &block) @model = model if from.respond_to?(:read) and from.respond_to?(:rewind) from.rewind @from = from.read else @from = from end @filename_callback = block end def name if @filename_callback @filename_callback.call(@model) else Tori.config.filename_callback.call(@model) end end alias to_s name def from? !@from.nil? end def write(opts = nil) Tori.config.backend.write name, @from, opts end def delete Tori.config.backend.delete name if exist? end def respond_to_missing?(sym, include_private) Tori.config.backend.respond_to?(sym, include_private) end def method_missing(sym, *args) if respond_to_missing?(sym, false) Tori.config.backend.__send__ sym, name, *args else fail NameError, "undefined method `#{sym}' for #{Tori.config.backend.inspect}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tori-0.3.0 | lib/tori/file.rb |