Skip to content

Instantly share code, notes, and snippets.

View st33n's full-sized avatar

Steen Lehmann st33n

View GitHub Profile
@st33n
st33n / account_example_with_context.rb
Created October 26, 2011 06:45
DCI example in Ruby
#!/usr/bin/env ruby
# Lean Architecture example in Ruby - with ContextAccessor
# This example keeps interaction state in a "current context", represented
# by a ContextAccessor module. This can be mixed in to any class that needs
# access to the current context. It is implemented as a thread-local variable.
module ContextAccessor
def context
Thread.current[:context]
@st33n
st33n / account_example_without_context.rb
Created October 26, 2011 06:46
DCI example in Ruby, without ContextAccessor
#!/usr/bin/env ruby
# Lean Architecture example in Ruby - without ContextAccessor
# In this example, the context passes the needed roles into each method it
# invokes, and so the roles have no reference back to the context.
# Model class with no external dependenices. Includes a simple find method
# to create and store instances given an id - for illustration purposes only.
class Account
attr_reader :account_id, :balance

Keybase proof

I hereby claim:

  • I am st33n on github.
  • I am slehmann (https://keybase.io/slehmann) on keybase.
  • I have a public key whose fingerprint is 0E5C 0058 F43E 81BB 3A57 9D98 5DFC A5E3 1531 84B0

To claim this, I am signing this object: