Class: Artifact::WritableFile
Instance Attribute Summary
Attributes inherited from ReadableFile
#full_path, #path
Instance Method Summary
collapse
#body, #dirname, #exists?, #filename, #initialize, #last_modified, #meta, #slug
Instance Method Details
#delete ⇒ Object
340
341
342
|
# File 'lib/artifact.rb', line 340
def delete
FileUtils.rm(full_path)
end
|
#save(new_content) ⇒ Object
323
324
325
326
327
328
|
# File 'lib/artifact.rb', line 323
def save(new_content)
Artifact.ensure_dir!(@full_path)
File.open(@full_path, 'wb') { |f| f.write(new_content) }
@content = nil
end
|
#update(new_content, meta = nil) ⇒ Object
330
331
332
333
334
335
336
337
338
|
# File 'lib/artifact.rb', line 330
def update(new_content, meta = nil)
if exists? and new_content == read
return puts "No changes. No need to write changes to disk."
end
Artifact.run_hook :before_update, new_content, @full_path
save(new_content)
Artifact.run_hook :after_update, new_content, @full_path
end
|