Class: CephRuby::Xattr

Inherits:
Object
  • Object
show all
Defined in:
lib/ceph-ruby/xattr.rb

Overview

Representation of a File extended Attribute

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rados_object, name) {|_self| ... } ⇒ Xattr

Returns a new instance of Xattr.

Yields:

  • (_self)

Yield Parameters:

Raises:

  • (Errno::ENOENT)


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ceph-ruby/xattr.rb', line 6

def initialize(rados_object, name)
  raise Errno::ENOENT, 'RadosObject is nil' unless rados_object.exists?
  raise SystemCallError.new(
    'xattr name cannot be nil',
    Errno::ENOENT::Errno
  ) if name.nil?
  self.rados_object = rados_object
  self.pool = rados_object.pool
  self.name = name
  yield(self) if block_given?
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/ceph-ruby/xattr.rb', line 4

def name
  @name
end

#poolObject

Returns the value of attribute pool.



4
5
6
# File 'lib/ceph-ruby/xattr.rb', line 4

def pool
  @pool
end

#rados_objectObject

Returns the value of attribute rados_object.



4
5
6
# File 'lib/ceph-ruby/xattr.rb', line 4

def rados_object
  @rados_object
end

Instance Method Details

#destroyObject

Raises:

  • (SystemCallError)


26
27
28
29
30
31
32
33
# File 'lib/ceph-ruby/xattr.rb', line 26

def destroy
  log('destroy')
  ret = Lib::Rados.rados_rmxattr(pool.handle,
                                 rados_object.name,
                                 name)
  raise SystemCallError.new("destruction of xattr '#{name}' failed",
                            -ret) if ret < 0
end

#log(message) ⇒ Object



39
40
41
42
# File 'lib/ceph-ruby/xattr.rb', line 39

def log(message)
  CephRuby.log('rados obj xattr '\
               "#{rados_object.name}/#{name} #{message}")
end

#to_sObject



35
36
37
# File 'lib/ceph-ruby/xattr.rb', line 35

def to_s
  read
end

#value(size = 4096) ⇒ Object



18
19
20
# File 'lib/ceph-ruby/xattr.rb', line 18

def value(size = 4096)
  read size
end

#value=(value) ⇒ Object



22
23
24
# File 'lib/ceph-ruby/xattr.rb', line 22

def value=(value)
  write value
end