Created
December 19, 2011 15:16
-
-
Save sevos/1497628 to your computer and use it in GitHub Desktop.
This file contains 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 User | |
def initialize(context) | |
@context = context | |
end | |
def profile | |
@context.system.collections.profiles.where(id: @context.session[:current_user_id]).first | |
end | |
end |
This file contains 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 Shop::SignupContext < ApplicationContext | |
def user | |
@user ||= User.new(self) | |
end | |
def system | |
@system ||= System.new(self) | |
end | |
def create | |
if user.extend(User::Guest).create_account(params[:profile]) | |
system.extend(System::Shop) | |
ProductsPresenter.new system.products.first(5) # just example, show 5 first products in response | |
end | |
end | |
end |
This file contains 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
module System::Shop | |
def products | |
@context.system.collections.products.where(shop_id: @context.session[:shop_id]) | |
end | |
end |
This file contains 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
module User::Guest | |
def create_account(account_attributes) | |
# ... | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment