Skip to content

Instantly share code, notes, and snippets.

@rebo
Created December 17, 2012 20:58
Show Gist options
  • Select an option

  • Save rebo/4322170 to your computer and use it in GitHub Desktop.

Select an option

Save rebo/4322170 to your computer and use it in GitHub Desktop.
require 'alias_dci'
class Player < Struct.new(:name)
include AliasDCI::DataObject
def foo
puts "Player's foo"
end
end
class TestContext
include AliasDCI::Context
role :a do
def foo
puts "A's Foo"
end
end
role :b
def initialize(player)
assign_named_roles(:a => player, :b => player)
end
def call
in_context do
a.foo
r_b.foo #explicitly call #foo through b
end
end
end
TestContext.new(Player.new).call
# => nil
# >> A's Foo
# >> Player's foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment