Module: Etcdv3::Namespace::Utilities
- Included in:
- KV, KV::Transaction, Lock, Watch
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/utilities.rb
Instance Method Summary collapse
- #delete_prefix(prefix, str) ⇒ Object
- #prepend_prefix(prefix, key) ⇒ Object
- #strip_prefix(prefix, resp) ⇒ Object
- #strip_prefix_from_events(prefix, events) ⇒ Object
- #strip_prefix_from_lock(prefix, resp) ⇒ Object
Instance Method Details
#delete_prefix(prefix, str) ⇒ Object
39 40 41 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/utilities.rb', line 39 def delete_prefix(prefix, str) str.sub(/\A#{prefix}/, '') end |
#prepend_prefix(prefix, key) ⇒ Object
4 5 6 7 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/utilities.rb', line 4 def prepend_prefix(prefix, key) key = key.dup if key.frozen? key.prepend(prefix) end |
#strip_prefix(prefix, resp) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/utilities.rb', line 9 def strip_prefix(prefix, resp) [:kvs, :prev_kvs].each do |field| if resp.respond_to?(field) resp.send(field).each do |kv| kv.key = delete_prefix(prefix, kv.key) end end end resp end |
#strip_prefix_from_events(prefix, events) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/utilities.rb', line 27 def strip_prefix_from_events(prefix, events) events.each do |event| if event.kv event.kv.key = delete_prefix(prefix, event.kv.key) end if event.prev_kv event.prev_kv.key = delete_prefix(prefix, event.prev_kv.key) end event end end |
#strip_prefix_from_lock(prefix, resp) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/utilities.rb', line 20 def strip_prefix_from_lock(prefix, resp) if resp.key resp.key = delete_prefix(prefix, resp.key) end resp end |