Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/upcastable/core_ext/object/upcasting.rb
Instance Method Summary collapse
-
#downcast ⇒ Object
Downcasts the object to the original class.
-
#upcast_to(ancestor) ⇒ Object
Upcasts the object to the specified class or module.
-
#upcasted? ⇒ true, false
Returns true if the object is upcasted.
-
#upcasting ⇒ Class, ...
The ancestor to which the object have been upcasted.
Instance Method Details
#downcast ⇒ Object
Downcasts the object to the original class
53 54 55 |
# File 'lib/upcastable/core_ext/object/upcasting.rb', line 53 def downcast self end |
#upcast_to(ancestor) ⇒ Object
Upcasts the object to the specified class or module. Internally, the upcasted object is a Upcastable::UpcastedObject instance which delegates almost all methods to the original object.
34 35 36 |
# File 'lib/upcastable/core_ext/object/upcasting.rb', line 34 def upcast_to(ancestor) ::Upcastable::UpcastedObject.new(self, ancestor) end |
#upcasted? ⇒ true, false
Returns true if the object is upcasted
46 47 48 |
# File 'lib/upcastable/core_ext/object/upcasting.rb', line 46 def upcasted? false end |
#upcasting ⇒ Class, ...
Returns the ancestor to which the object have been upcasted.
39 40 41 |
# File 'lib/upcastable/core_ext/object/upcasting.rb', line 39 def upcasting nil end |