Skip to content

Instantly share code, notes, and snippets.

@katpadi
Last active August 29, 2015 14:22
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 katpadi/02b51d512da925c2b7aa to your computer and use it in GitHub Desktop.
Save katpadi/02b51d512da925c2b7aa to your computer and use it in GitHub Desktop.
SomethingBuilder
class SomethingBuilder
def initialize(something)
@something = something
end
def build
build_something_after_something_else
end
private
def build_something_after_something_else
# Update model A
# Insert to model B
# Insert to model A and B mapping
end
end
class AController < ApplicationController
def create
# Do the usual stuff here...
# Then, use the service!
SomethingBuilder.new(@a).build
end
# Other controller actions here...
end
class BController < ApplicationController
def create
# Do the usual stuff here...
# Then, use the service!
SomethingBuilder.new(@b).build
end
# Other controller actions here...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment