Created
August 19, 2012 11:46
-
-
Save clowder/3394426 to your computer and use it in GitHub Desktop.
Pattern Wank
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EntityController < ApplicationController | |
respond_to :json | |
def create | |
entity = Entity.new(post_params) | |
validator = EntityValidator.new(entity) | |
if validator.passes? | |
collection = EntityRepository.add(entity) | |
respond_with EntityPresenter.new(entity) | |
else | |
render :json => validator.errors.to_json, :status => :unprocessable_entity | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Made rookie DDD mistake of conflating Repository Pattern with DDD. Informative exercise all the same.