Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/role_playing/core_ext.rb
Overview
PLEASE NOTE: This is almost completely unnecessary except for some syntax sugar which I like. It basically does this: TheRole.new(theObject) and returns it and also runs an instance_eval if a block was given. It can also take many Roles, not just one so you could do theObject.as(SomeRole, AnotherRole).
Instance Method Summary collapse
Instance Method Details
#played_by(object) ⇒ Object
6 7 8 9 |
# File 'lib/role_playing/core_ext.rb', line 6 def played_by(object) extended = self.inject(object) { |extended, role| role.new(extended) } block_given? ? yield(extended) : extended end |