Class: Decidim::Posts::DestroyPost
- Inherits:
-
Command
- Object
- Command
- Decidim::Posts::DestroyPost
- Defined in:
- app/commands/decidim/posts/destroy_post.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(post, current_user) ⇒ DestroyPost
constructor
A new instance of DestroyPost.
Constructor Details
#initialize(post, current_user) ⇒ DestroyPost
Returns a new instance of DestroyPost.
6 7 8 9 |
# File 'app/commands/decidim/posts/destroy_post.rb', line 6 def initialize(post, current_user) @post = post @current_user = current_user end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/commands/decidim/posts/destroy_post.rb', line 11 def call return broadcast(:invalid) unless @post.(@current_user) || @current_user.admin? @post.destroy! broadcast(:ok, @post) end |