role_playing 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/role_playing/dci.rb +1 -2
- data/lib/role_playing/version.rb +1 -1
- data/spec/role_playing/dci_spec.rb +7 -0
- metadata +1 -1
data/lib/role_playing/dci.rb
CHANGED
@@ -24,8 +24,7 @@ end
|
|
24
24
|
class Object
|
25
25
|
def in_roles(*roles, &block)
|
26
26
|
extended = roles.inject(self) { |extended, role| role.new(extended) }
|
27
|
-
extended
|
28
|
-
extended
|
27
|
+
block_given? ? yield(extended) : extended
|
29
28
|
end
|
30
29
|
def in_role(role, &block)
|
31
30
|
in_roles(*role, &block)
|
data/lib/role_playing/version.rb
CHANGED
@@ -75,6 +75,13 @@ describe RolePlaying do
|
|
75
75
|
subject.role_player.should_not respond_to(:two_fields)
|
76
76
|
end
|
77
77
|
|
78
|
+
it "#in_role takes a block and returns the result" do
|
79
|
+
two_fields = bare_object.in_role(MyRole) do |role|
|
80
|
+
role.two_fields
|
81
|
+
end
|
82
|
+
two_fields.should == "#{bare_object.field_1} #{bare_object.field_2}"
|
83
|
+
end
|
84
|
+
|
78
85
|
end
|
79
86
|
|
80
87
|
context MoneyTransfer do
|