class WrapperBased::Casting::Type

Attributes

name[R]

Public Class Methods

new(name, talent_pool) click to toggle source
# File lib/wrapper_based/casting/type.rb, line 7
def initialize(name, talent_pool)
  @name = name.to_sym
  @talents = Set.new
  @lookup = talent_pool
end

Public Instance Methods

[](*where) click to toggle source
# File lib/wrapper_based/casting/type.rb, line 18
def [](*where)
  @lookup[where]
end
cast_type(type) click to toggle source
# File lib/wrapper_based/casting/type.rb, line 22
def cast_type(type)
  self[type, *@talents]
end
has(talent) click to toggle source
# File lib/wrapper_based/casting/type.rb, line 13
def has(talent)
  @talents << talent
  self
end
typecast(actor) click to toggle source
# File lib/wrapper_based/casting/type.rb, line 26
def typecast(actor)
  return actor if @talents.empty?
  cast_type(actor.class).new actor
end