Your browser doesn't support the features required by impress.js, so you are presented with a simplified version of this presentation.
For the best experience please use the latest Chrome, Safari or Firefox browser.
module Publisher
def publish(post)
post.publish
end
end
Roles should:
class UserPublishesPostContext
def initialize(user, post)
@publisher, @post = user, post
@publisher.extend Publisher # extend instance!
end
def call
@publisher.publish(@post)
end
end
# Within the controller...
@user = current_user
@post = Post.find(params[:id])
UserPublishesPostContext.new(@user, @post).call
class Post < ActiveRecord::Base
validates :title, :presence => true
def publish
update_attribute(:published_at, Time.zone.now)
end
end
Data should: