Module: CephStorage::StorageObject

Included in:
FileStorageObject, RadosStorageObject, URLStorageObject
Defined in:
lib/ceph_storage/storage_object.rb,
lib/ceph_storage/storage_object/xattr.rb,
lib/ceph_storage/storage_object/rados_wrapper.rb,
lib/ceph_storage/storage_object/xattr_enumerator.rb,
lib/ceph_storage/storage_object/url_storage_object.rb,
lib/ceph_storage/storage_object/file_storage_object.rb,
lib/ceph_storage/storage_object/rados_storage_object.rb,
lib/ceph_storage/storage_object/rados_storage_object_enumerator.rb

Overview

core representation of a file. This is a mixin module for other storage object modules

Defined Under Namespace

Modules: RadosWrapper Classes: FileStorageObject, RadosStorageObject, RadosStorageObjectEnumerator, URLStorageObject, Xattr, XattrEnumerator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Represent an object that can be written to or read from This is designed to be modular so that you can expand into other technologies



9
10
11
# File 'lib/ceph_storage/storage_object.rb', line 9

def name
  @name
end

Class Method Details

.supports_xattr?(obj) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/ceph_storage/storage_object.rb', line 39

def supports_xattr?(obj)
  obj.respond_to? :xattr_enumerator
end

Instance Method Details

#copy(dst_object) ⇒ Object



17
18
19
20
21
# File 'lib/ceph_storage/storage_object.rb', line 17

def copy(dst_object)
  log("copy to '#{dst_object.class}/#{dst_object.name}'")
  dst_object.write_file(read_file)
  copy_xattrs(dst_object)
end

#copy_xattrs(dst_object) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/ceph_storage/storage_object.rb', line 23

def copy_xattrs(dst_object)
  log('copy xattrs')
  return unless xattr_supported?(dst_object)
  xattr_enumerator.each do |source_xattr|
    dst_object.xattr(source_xattr.name) do |dst_xattr|
      dst_xattr.value = source_xattr.value
    end
  end
end

#log(message) ⇒ Object



44
45
46
# File 'lib/ceph_storage/storage_object.rb', line 44

def log(message)
  CephStorage.log("storage object #{name} #{message}")
end

#move(dst_object) ⇒ Object



10
11
12
13
14
15
# File 'lib/ceph_storage/storage_object.rb', line 10

def move(dst_object)
  log("move to '#{dst_object.class}/#{dst_object.name}'")
  dst_object.write_file(read_file)
  copy_xattrs(dst_object)
  destroy
end

#xattr_supported?(dst_object) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
# File 'lib/ceph_storage/storage_object.rb', line 33

def xattr_supported?(dst_object)
  CephStorage::StorageObject.supports_xattr?(self) &&
    CephStorage::StorageObject.supports_xattr?(dst_object)
end