mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
34 lines
No EOL
689 B
Ruby
34 lines
No EOL
689 B
Ruby
require 'fog/core/collection'
|
|
require 'fog/aws/models/storage/version'
|
|
|
|
module Fog
|
|
module Storage
|
|
class AWS
|
|
|
|
class Versions < Fog::Collection
|
|
|
|
attribute :file
|
|
|
|
model Fog::Storage::AWS::Version
|
|
|
|
def all
|
|
data = connection.get_bucket_object_versions(file.directory.key, :prefix => file.key).body['Versions']
|
|
load(data)
|
|
end
|
|
|
|
def new(attributes = {})
|
|
requires :file
|
|
|
|
version_type = attributes.keys.first
|
|
|
|
model = super({ :file => file }.merge!(attributes[version_type]))
|
|
model.delete_marker = version_type == 'DeleteMarker'
|
|
|
|
model
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|
|
end |