Class: WrapperBased::Casting::Director
- Inherits:
-
Struct
- Object
- Struct
- WrapperBased::Casting::Director
- Defined in:
- lib/wrapper_based/casting/director.rb
Instance Attribute Summary collapse
-
#casting ⇒ Object
Returns the value of attribute casting.
-
#talent_pool ⇒ Object
Returns the value of attribute talent_pool.
Instance Method Summary collapse
- #adds(role, talent = TALENTLESS) ⇒ Object
-
#initialize(talent_pool) ⇒ Director
constructor
A new instance of Director.
- #to_proc ⇒ Object
- #type_for(role) ⇒ Object
Constructor Details
Instance Attribute Details
#casting ⇒ Object
Returns the value of attribute casting
4 5 6 |
# File 'lib/wrapper_based/casting/director.rb', line 4 def casting @casting end |
#talent_pool ⇒ Object
Returns the value of attribute talent_pool
4 5 6 |
# File 'lib/wrapper_based/casting/director.rb', line 4 def talent_pool @talent_pool end |
Instance Method Details
#adds(role, talent = TALENTLESS) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/wrapper_based/casting/director.rb', line 7 def adds(role, talent = TALENTLESS) case talent when ::Proc, ::Method, ::Symbol casting.casts role, &talent when ::Class casting.casts role, &talent.method(:new) when ::Module casting.casts_as role, &type_for(role).has(talent).method(:typecast) else throw :wrong_talent_type, [role, talent, "expected Module, Class, Proc, Method or Symbol"] end end |
#to_proc ⇒ Object
20 21 22 |
# File 'lib/wrapper_based/casting/director.rb', line 20 def to_proc method(:adds).to_proc end |