Class: Pulitzer::PostsController::Update
- Inherits:
-
Object
- Object
- Pulitzer::PostsController::Update
- Includes:
- Validations
- Defined in:
- app/interactions/pulitzer/posts_controller/update.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(post, params) ⇒ Update
constructor
A new instance of Update.
Methods included from Validations
Constructor Details
#initialize(post, params) ⇒ Update
Returns a new instance of Update.
4 5 6 |
# File 'app/interactions/pulitzer/posts_controller/update.rb', line 4 def initialize(post, params) @post, @params = post, params end |
Instance Method Details
#call ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'app/interactions/pulitzer/posts_controller/update.rb', line 8 def call @post.assign_attributes @params if @post.changes.keys.map(&:to_sym).include?(:title) validate_title or return @post @post.slug = nil end @post.save @post end |