Class: Fog::Local::File

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/local/models/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.



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

def body
  @body
end

Instance Method Details

#destroyObject



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

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

#directoryObject



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

def directory
  @directory
end

#save(options = {}) ⇒ Object



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

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