Skip to content

Instantly share code, notes, and snippets.

#
# Fight.rb - showing overiding of instance methods and rebinding of a context.
#
#
#
#
require 'alias_dci'
require 'alias_dci'
class Player < Struct.new(:name)
include AliasDCI::DataObject
def foo
puts "Player's foo"
end
end
class TestContext
@rebo
rebo / abc.rb
Created December 19, 2012 10:26
require 'alias_dci' # !> previous definition of r_z was here
# Class a{
# void foo(){
# Print "a";
# }
# }
class A
include AliasDCI::DataObject
def foo
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
@rebo
rebo / sub.rb
Created December 19, 2012 15:37
require 'alias_dci'
class Player
include AliasDCI::DataObject
def foo(str)
str + "b"
end
def to_string
"a"
require 'alias_dci'
class Person
include AliasDCI::DataObject
def point(thing)
p "I'm using my finger to point at #{thing}"
end
end
@rebo
rebo / gist:4339983
Created December 19, 2012 20:04 — forked from runefs/gist:4338821
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
module Authentication
def authenticate!
# authentication check
end
end
class PurchasingProcess
include AliasDCI::Context
role :authenticating_user, Authentication
#
# 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
#
# 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