Class: Textus::Write::Delete
- Inherits:
-
Object
- Object
- Textus::Write::Delete
- Defined in:
- lib/textus/write/delete.rb
Instance Method Summary collapse
- #call(key, if_etag: nil, suppress_events: false) ⇒ Object
-
#initialize(container:, call:) ⇒ Delete
constructor
A new instance of Delete.
Constructor Details
#initialize(container:, call:) ⇒ Delete
Returns a new instance of Delete.
4 5 6 7 8 9 10 |
# File 'lib/textus/write/delete.rb', line 4 def initialize(container:, call:) @container = container @call = call @manifest = container.manifest @authorizer = container. @events = container.events end |
Instance Method Details
#call(key, if_etag: nil, suppress_events: false) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/textus/write/delete.rb', line 12 def call(key, if_etag: nil, suppress_events: false) Textus::Manifest::Data.validate_key!(key) mentry = @manifest.resolver.resolve(key).entry @authorizer.(mentry, role: @call.role) writer.delete(key, mentry: mentry, if_etag: if_etag) unless suppress_events @events.publish(:entry_deleted, ctx: hook_context, key: key) end { "protocol" => Textus::PROTOCOL, "ok" => true, "key" => key, "deleted" => true } end |