Class: DSLCompose::ClassCoerce

Inherits:
Object
  • Object
show all
Defined in:
lib/dsl_compose/class_coerce.rb

Defined Under Namespace

Classes: UnexpectedClassNameError

Instance Attribute Summary collapse

Instance Method Summary collapse

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_nameObject (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_classObject



18
19
20
# File 'lib/dsl_compose/class_coerce.rb', line 18

def to_class
  Object.const_get @class_name
end