Skip to content

Instantly share code, notes, and snippets.

@usmonster
Created May 15, 2012 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save usmonster/2700041 to your computer and use it in GitHub Desktop.
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?
// ...
@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)
}
// ...
# ...
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