module DeepStore::Model::ContentInterface
Public Class Methods
included(base)
click to toggle source
# File lib/deep_store/model/content_interface.rb, line 4 def self.included(base) base.class_eval do extend Forwardable attr_reader :sweeper def_delegators :content, :read, :write, :rewind, :each, :puts, :close, :unlink def reload @content = nil end def content return @content if @content self.content = persisted? ? __repository__.get(key).stream : Tempfile.new end def content=(stream) @content = stream @sweeper = Sweeper.register(self, stream) end def finalize sweeper&.finalize end end end
Public Instance Methods
content()
click to toggle source
# File lib/deep_store/model/content_interface.rb, line 16 def content return @content if @content self.content = persisted? ? __repository__.get(key).stream : Tempfile.new end
content=(stream)
click to toggle source
# File lib/deep_store/model/content_interface.rb, line 21 def content=(stream) @content = stream @sweeper = Sweeper.register(self, stream) end
finalize()
click to toggle source
# File lib/deep_store/model/content_interface.rb, line 26 def finalize sweeper&.finalize end
reload()
click to toggle source
# File lib/deep_store/model/content_interface.rb, line 12 def reload @content = nil end