Class: Fog::Local::Storage::File
- Inherits:
-
Model
- Object
- Model
- Fog::Local::Storage::File
show all
- Defined in:
- lib/fog/local/models/storage/file.rb
Instance Attribute Summary collapse
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
Methods inherited from Model
#initialize, #inspect, #reload, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires
Constructor Details
This class inherits a constructor from Fog::Model
Instance Attribute Details
#body ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/fog/local/models/storage/file.rb', line 16
def body
@body ||= if last_modified
collection.get(identity).body
else
''
end
end
|
Instance Method Details
#destroy ⇒ Object
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
|
#directory ⇒ Object
24
25
26
|
# File 'lib/fog/local/models/storage/file.rb', line 24
def directory
@directory
end
|
#public_url ⇒ Object
34
35
36
|
# File 'lib/fog/local/models/storage/file.rb', line 34
def public_url
nil
end
|
#save(options = {}) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/fog/local/models/storage/file.rb', line 38
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
|