Skip to content

Instantly share code, notes, and snippets.

@nthx
Created March 13, 2012 14:01
Show Gist options
  • Save nthx/2028946 to your computer and use it in GitHub Desktop.
Save nthx/2028946 to your computer and use it in GitHub Desktop.
god_systems_god_1
class Ebay
constructor: ->
#I'm yet to decide if static vs dynamic roles' assignment
#is better. It doesn't matter so much for now
#extend(@, EbayCanBeWatchedRole)
#extend(@, SellersCanListRole)
class EbayCanBeWatchedRole
is_already_watching_item: (seller, item) =>
storage().is_seller_watching(item)
seller_wants_to_watch_item: (seller, item) =>
if @is_already_watching_item(seller, item)
throw new AlreadyWatching()
storage().seller_starts_watching(item)
class ListingItemAnswer
listing_is_valid: () =>
errors: () =>
mark_ok: () =>
class SellersCanListRole
list_items: (seller, item_definition) =>
answer = new ListingItemAnswer()
if @is_valid(item_definition) and @can_seller_list(seller)
@schedule_for_listing(seller, item_definition)
answer.mark_ok()
#...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment