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