Class: Fog::Rackspace::Files::File

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

Instance Attribute Summary

Attributes inherited from Model

#connection

Instance Method Summary collapse

Methods inherited from Model

#_dump, _load, aliases, attribute, attributes, #attributes, #collection, identity, #identity, #initialize, #inspect, #merge_attributes, #new_record?, #reload, #requires, #wait_for

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#bodyObject



15
16
17
18
19
20
21
# File 'lib/fog/rackspace/models/files/file.rb', line 15

def body
  @body ||= if last_modified
    collection.get(identity).body
  else
    ''
  end
end

#destroyObject



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

def destroy
  requires :directory, :key
  connection.delete_object(directory.name, @key)
  true
end

#directoryObject



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

def directory
  @directory
end

#owner=(new_owner) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/fog/rackspace/models/files/file.rb', line 33

def owner=(new_owner)
  if new_owner
    @owner = {
      :display_name => new_owner['DisplayName'],
      :id           => new_owner['ID']
    }
  end
end

#save(options = {}) ⇒ Object



42
43
44
45
46
47
# File 'lib/fog/rackspace/models/files/file.rb', line 42

def save(options = {})
  requires :body, :directory, :key
  data = connection.put_object(directory.name, @key, @body, options)
  @etag = data.headers['ETag']
  true
end