Class: Fog::Local::Storage::File

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/local/models/storage/file.rb

Instance Attribute Summary collapse

Attributes inherited from Model

#connection

Instance Method Summary collapse

Methods inherited from Model

#collection, #initialize, #inspect, #reload, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires

Constructor Details

This class inherits a constructor from Fog::Model

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



11
12
13
# File 'lib/fog/local/models/storage/file.rb', line 11

def body
  @body
end

Instance Method Details

#destroyObject



28
29
30
31
32
# File 'lib/fog/local/models/storage/file.rb', line 28

def destroy
  requires :directory, :key
  ::File.delete(path)
  true
end

#directoryObject



24
25
26
# File 'lib/fog/local/models/storage/file.rb', line 24

def directory
  @directory
end

#save(options = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/local/models/storage/file.rb', line 34

def save(options = {})
  requires :body, :directory, :key
  file = ::File.new(path, 'w')
  file.write(body)
  file.close
  merge_attributes(
    :content_length => ::File.size(path),
    :last_modified  => ::File.mtime(path)
  )
  true
end