Class: Structural::Model::TypeCasts::Cast
- Inherits:
-
Object
- Object
- Structural::Model::TypeCasts::Cast
show all
- Defined in:
- lib/structural/model/type_casts.rb
Instance Method Summary
collapse
Constructor Details
#initialize(value) ⇒ Cast
Returns a new instance of Cast.
21
22
23
|
# File 'lib/structural/model/type_casts.rb', line 21
def initialize(value)
@value = value
end
|
Instance Method Details
#cast ⇒ Object
25
26
27
|
# File 'lib/structural/model/type_casts.rb', line 25
def cast
value.is_a?(type) ? value : conversion
end
|
#conversion ⇒ Object
33
34
35
|
# File 'lib/structural/model/type_casts.rb', line 33
def conversion
raise NotImplementedError
end
|
#type ⇒ Object
29
30
31
|
# File 'lib/structural/model/type_casts.rb', line 29
def type
self.class.type
end
|