Class: Compony::Components::Destroy
- Inherits:
-
Compony::Component
- Object
- Compony::Component
- Compony::Components::Destroy
- Includes:
- Compony::ComponentMixins::Resourceful
- Defined in:
- lib/compony/components/destroy.rb
Overview
This component is used for the Rails destroy paradigm. Asks for confirm when queried using GET.
Instance Attribute Summary
Attributes included from Compony::ComponentMixins::Resourceful
#data, #global_after_assign_attributes_block, #global_after_load_data_block, #global_assign_attributes_block, #global_load_data_block, #global_store_data_block
Attributes inherited from Compony::Component
#comp_opts, #content_blocks, #parent_comp
DSL collapse
-
#on_destroyed { ... } ⇒ void
DSL method Sets an optional hook evaluated (with backfire) after a successful destroy but before responding.
-
#on_destroyed_redirect_path { ... } ⇒ void
DSL method Overrides the redirect target used by the default #on_destroyed_respond (keeping the default flash).
-
#on_destroyed_respond { ... } ⇒ void
DSL method Overrides the response issued after a successful destroy.
Methods included from Compony::ComponentMixins::Resourceful
#after_assign_attributes, #after_load_data, #assign_attributes, #data_class, #initialize, #load_data, #resourceful?, #store_data
Methods inherited from Compony::Component
#before_render, comp_name, #content, #exposed_intents, family_name, #id, #id_path, #id_path_hash, #initialize, #inspect, #param_name, #path, #remove_content, #remove_content!, #render, #resourceful?, #root_comp, #root_comp?, setup, #sub_comp
Instance Method Details
#on_destroyed { ... } ⇒ void
This method returns an undefined value.
DSL method
Sets an optional hook evaluated (with backfire) after a successful destroy but before responding.
Suitable for post-destroy side effects (like an after_destroy that only fires when this component destroyed the record).
Do not redirect or render here - use #on_destroyed_respond / #on_destroyed_redirect_path for that.
90 91 92 |
# File 'lib/compony/components/destroy.rb', line 90 def on_destroyed(&block) @on_destroyed_block = block end |
#on_destroyed_redirect_path { ... } ⇒ void
This method returns an undefined value.
DSL method Overrides the redirect target used by the default #on_destroyed_respond (keeping the default flash). Defaults to the owner's Show (if owned) or the data's Index.
111 112 113 |
# File 'lib/compony/components/destroy.rb', line 111 def on_destroyed_redirect_path(&block) @on_destroyed_redirect_path_block = block end |
#on_destroyed_respond { ... } ⇒ void
This method returns an undefined value.
DSL method Overrides the response issued after a successful destroy. The default shows a flash and redirects to #on_destroyed_redirect_path with HTTP 303 (forces a GET, required for Turbo). If you override this, #on_destroyed_redirect_path is no longer called.
101 102 103 |
# File 'lib/compony/components/destroy.rb', line 101 def on_destroyed_respond(&block) @on_destroyed_respond_block = block end |