Class: Fog::Local::Storage::File
- Inherits:
-
Model
- Object
- Model
- Fog::Local::Storage::File
show all
- Defined in:
- lib/fog/storage/models/local/file.rb
Instance Attribute Summary
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 Method Details
#body ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/fog/storage/models/local/file.rb', line 15
def body
attributes[:body] ||= if last_modified
collection.get(identity).body
else
''
end
end
|
#body=(new_body) ⇒ Object
23
24
25
|
# File 'lib/fog/storage/models/local/file.rb', line 23
def body=(new_body)
attributes[:body] = new_body
end
|
#destroy ⇒ Object
31
32
33
34
35
|
# File 'lib/fog/storage/models/local/file.rb', line 31
def destroy
requires :directory, :key
::File.delete(path)
true
end
|
#directory ⇒ Object
27
28
29
|
# File 'lib/fog/storage/models/local/file.rb', line 27
def directory
@directory
end
|
#public=(new_public) ⇒ Object
37
38
39
|
# File 'lib/fog/storage/models/local/file.rb', line 37
def public=(new_public)
new_public
end
|
#public_url ⇒ Object
41
42
43
|
# File 'lib/fog/storage/models/local/file.rb', line 41
def public_url
nil
end
|
#save(options = {}) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/fog/storage/models/local/file.rb', line 45
def save(options = {})
requires :body, :directory, :key
file = ::File.new(path, 'w')
if body.is_a?(String)
file.write(body)
else
file.write(body.read)
end
file.close
merge_attributes(
:content_length => ::File.size(path),
:last_modified => ::File.mtime(path)
)
true
end
|