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

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/rackspace/models/files/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/rackspace/models/files/file.rb', line 11

def body
  @body
end

Instance Method Details

#destroyObject



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

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

#directoryObject



25
26
27
# File 'lib/fog/rackspace/models/files/file.rb', line 25

def directory
  @directory
end

#owner=(new_owner) ⇒ Object



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

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

#saveObject



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

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