adomokos/light-service — pull request #12 by house9 (2013-06-18 23:33:29+00:00)
Title: skip_all option, similar to failure but used for non failure scenarios

Not sure if you want to introduce this or not? I have only been using light-service for a few hours so it is possible the code I came up with is smelly and that is why I encountered the need for `skip_all!` option

here is a contrived example to demonstrate usage - see `SaveCommentAction` for skip_all!

```ruby
def add_comment
@post = Post.find(params[:id])
@comment = Comment.new(params[:comment])
service_result = AddComment.to_post({ post: @post, comment: @comment })
# ...
end

def approve_comment
post = current_user.posts.find(params[:id])
comment = @post.comments.find(params[:comment_id])
service_result = ApproveComment.for_comment(comment)
# ...
end

class AddComment
extend LightService::Organizer

def self.to_post(args = {})
with(args).reduce [
SaveCommentAction,
PublishCommentAction
]
end
end

class ApproveComment
extend LightService::Organizer

def self.for_comment(comment)
with(comment: comment).reduce [
PublishCommentAction,
SendNoticeToCommenterAction
]
end
end

class SaveCommentAction
include LightService::Action

executed do |context|
comment = context.fetch(:comment)
post = context.fetch(:post)

post.comments << comment

unless comment.commenter.can_auto_approve_own_comment
context.skip_all!
end
end
end

class PublishCommentAction
include LightService::Action

executed do |context|
comment = context.fetch(:comment)
comment.update_attribute(:published, true)
end
end

class SendNoticeToCommenterAction
include LightService::Action

executed do |context|
comment = context.fetch(:comment)
CommentMailer.send_confirmation(comment).deliver
end
end
```