Created
December 17, 2012 20:58
-
-
Save rebo/4322170 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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