Class: Virtus::Coercion::Object
- Inherits:
-
Virtus::Coercion
- Object
- Virtus::Coercion
- Virtus::Coercion::Object
- Defined in:
- lib/virtus/coercion/object.rb
Overview
Coerce Object values
Direct Known Subclasses
Array, Date, DateTime, FalseClass, Hash, Numeric, String, Symbol, Time, TrueClass
Constant Summary collapse
- COERCION_METHOD_REGEXP =
/\Ato_/.freeze
Constants included from TypeLookup
Class Method Summary collapse
-
.to_array(value) ⇒ Array
Create an Array from any Object.
-
.to_hash(value) ⇒ Hash, Object
Create a Hash from the Object if possible.
-
.to_integer(value) ⇒ Integer, Object
Create an Integer from the Object if possible.
-
.to_string(value) ⇒ String, Object
Create a String from the Object if possible.
Methods inherited from Virtus::Coercion
Methods included from TypeLookup
#determine_type, extended, #primitive
Methods included from Options
#accept_options, #accepted_options, #options
Class Method Details
.to_array(value) ⇒ Array
Create an Array from any Object
27 28 29 |
# File 'lib/virtus/coercion/object.rb', line 27 def self.to_array(value) Array(value) end |
.to_hash(value) ⇒ Hash, Object
Create a Hash from the Object if possible
47 48 49 |
# File 'lib/virtus/coercion/object.rb', line 47 def self.to_hash(value) coerce_with_method(value, :to_hash) end |