Skip to content

Instantly share code, notes, and snippets.

@sevos
Created December 19, 2011 15:16
Show Gist options
  • Save sevos/1497628 to your computer and use it in GitHub Desktop.
Save sevos/1497628 to your computer and use it in GitHub Desktop.
class User
def initialize(context)
@context = context
end
def profile
@context.system.collections.profiles.where(id: @context.session[:current_user_id]).first
end
end
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
module System::Shop
def products
@context.system.collections.products.where(shop_id: @context.session[:shop_id])
end
end
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