Created
May 15, 2012 08:30
-
-
Save usmonster/2700041 to your computer and use it in GitHub Desktop.
Maybe we don't need to modify anything (signaturewise)? Maybe this is enough?
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
// ... | |
@Signature(parameters=Array("post_type", "subdomain", "group", "title", "body", "author")) | |
def create_post(post_type: String, subdomain: String, group: String, title:String = null, body:String, author:String) = wrap { | |
// not sure if this is efficient, but you get the idea | |
val CreatePost = post_type match { | |
case "short_post" => CreateShortPost(GroupRef(subdomain, group), body, UserRef(author)) | |
case "long_post" => CreateLongPost(GroupRef(subdomain, group), title, body, UserRef(author)) | |
// ... case else invalid | |
} | |
driver.runReadWrite(CreatePost) | |
} | |
// ... |
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
# ... | |
def create | |
post_type = params[:post][:type] | |
params[:post][:post_type] = post_type | |
params[:post]['subdomain'] = @subdomain | |
params[:post]['author'] = @author | |
@post = Post.create_post(params[:post]) | |
@errors = { errors: 'Unknown post type.' } unless @post.valid? | |
# ... | |
end | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment