Class: CephRuby::XattrEnumerator
- Inherits:
-
Object
- Object
- CephRuby::XattrEnumerator
- Includes:
- Enumerable
- Defined in:
- lib/ceph-ruby/xattr_enumerator.rb
Overview
Enumerator for Ceph Rados Objects Xattr
Instance Attribute Summary collapse
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
-
#object ⇒ Object
Returns the value of attribute object.
-
#pool ⇒ Object
Returns the value of attribute pool.
Instance Method Summary collapse
- #close ⇒ Object
- #each ⇒ Object
-
#initialize(object) ⇒ XattrEnumerator
constructor
A new instance of XattrEnumerator.
- #open ⇒ Object
- #open? ⇒ Boolean
Constructor Details
#initialize(object) ⇒ XattrEnumerator
Returns a new instance of XattrEnumerator.
9 10 11 12 13 |
# File 'lib/ceph-ruby/xattr_enumerator.rb', line 9 def initialize(object) self.object = object self.pool = object.pool open end |
Instance Attribute Details
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
7 8 9 |
# File 'lib/ceph-ruby/xattr_enumerator.rb', line 7 def handle @handle end |
#object ⇒ Object
Returns the value of attribute object.
6 7 8 |
# File 'lib/ceph-ruby/xattr_enumerator.rb', line 6 def object @object end |
#pool ⇒ Object
Returns the value of attribute pool.
6 7 8 |
# File 'lib/ceph-ruby/xattr_enumerator.rb', line 6 def pool @pool end |
Instance Method Details
#close ⇒ Object
15 16 17 18 |
# File 'lib/ceph-ruby/xattr_enumerator.rb', line 15 def close Lib::Rados.rados_getxattrs_end(handle) @handle = nil end |
#each ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ceph-ruby/xattr_enumerator.rb', line 33 def each return enum_for(:each) unless block_given? open loop do obj = next_xattr_object break if obj.nil? yield obj end close end |
#open ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/ceph-ruby/xattr_enumerator.rb', line 24 def open return if open? pool.ensure_open handle_p = FFI::MemoryPointer.new(:pointer) ret = Lib::Rados.rados_getxattrs(pool.handle, object.name, handle_p) raise SystemCallError.new('unable to open xattr list', -ret) if ret < 0 @handle = handle_p.get_pointer(0) end |
#open? ⇒ Boolean
20 21 22 |
# File 'lib/ceph-ruby/xattr_enumerator.rb', line 20 def open? !handle.nil? end |