Class: DSLCompose::ClassCoerce
- Inherits:
-
Object
- Object
- DSLCompose::ClassCoerce
- Defined in:
- lib/dsl_compose/class_coerce.rb
Defined Under Namespace
Classes: UnexpectedClassNameError
Instance Attribute Summary collapse
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
Instance Method Summary collapse
-
#initialize(class_name) ⇒ ClassCoerce
constructor
A new instance of ClassCoerce.
- #to_class ⇒ Object
Constructor Details
#initialize(class_name) ⇒ ClassCoerce
Returns a new instance of ClassCoerce.
10 11 12 13 14 15 16 |
# File 'lib/dsl_compose/class_coerce.rb', line 10 def initialize class_name unless class_name.is_a? String raise UnexpectedClassNameError, "expected `#{class_name}` to be a String" end @class_name = class_name end |
Instance Attribute Details
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
8 9 10 |
# File 'lib/dsl_compose/class_coerce.rb', line 8 def class_name @class_name end |
Instance Method Details
#to_class ⇒ Object
18 19 20 |
# File 'lib/dsl_compose/class_coerce.rb', line 18 def to_class Object.const_get @class_name end |