Class: RolePlaying::Role

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/role_playing/role.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.played_by(object) ⇒ Object



7
8
9
10
# File 'lib/role_playing/role.rb', line 7

def played_by(object)
  role = new(object)
  block_given? ? yield(role) : role
end

Instance Method Details

#classObject



13
14
15
# File 'lib/role_playing/role.rb', line 13

def class
  role_player.class ## this makes self.class return the extended objects class instead of DCIRole - should make the extension completely transparent
end

#role_playerObject

return the FINAL wrapped object



18
19
20
21
22
23
24
# File 'lib/role_playing/role.rb', line 18

def role_player
  player = self
  while player.respond_to?(:__getobj__)
    player = player.__getobj__
  end
  player
end