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
# | |
# Fight.rb - showing overiding of instance methods and rebinding of a context. | |
# | |
# | |
# | |
# | |
require 'alias_dci' |
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 |
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' # !> previous definition of r_z was here | |
# Class a{ | |
# void foo(){ | |
# Print "a"; | |
# } | |
# } | |
class A | |
include AliasDCI::DataObject | |
def foo |
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 Person | |
include AliasDCI::DataObject | |
def point(thing) | |
p "As a #{dci_roles.last||'Regular Person'} I am using my finger to point at #{thing}" | |
end | |
end |
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 | |
include AliasDCI::DataObject | |
def foo(str) | |
str + "b" | |
end | |
def to_string | |
"a" |
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 Person | |
include AliasDCI::DataObject | |
def point(thing) | |
p "I'm using my finger to point at #{thing}" | |
end | |
end |
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 A | |
include AliasDCI::DataObject | |
def foo | |
"a" | |
end | |
end | |
class C | |
include AliasDCI::Context # No need to also include DataObject in a context, it is one anyway |
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
# | |
# Simple Context Example: | |
# | |
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")) | |
require 'hybrid_dci' | |
Foo = Struct.new(:name) do | |
include HybridDCI::Data | |
end |
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
# | |
# Simple Context Example: | |
# | |
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")) | |
require 'hybrid_dci' | |
Foo = Struct.new(:name) do | |
include HybridDCI::Data | |
end |