Module: Virtus::Attributes::Typecast::Time
- Includes:
- Numeric
- Included in:
- Date, DateTime, Virtus::Attributes::Time
- Defined in:
- lib/virtus/attributes/typecast/time.rb
Instance Method Summary collapse
-
#extract_time(value) ⇒ Array
private
Extracts the given args from the hash.
Methods included from Numeric
Instance Method Details
#extract_time(value) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts the given args from the hash. If a value does not exist, it uses the value of Time.now.
17 18 19 20 21 22 23 |
# File 'lib/virtus/attributes/typecast/time.rb', line 17 def extract_time(value) now = ::Time.now [ :year, :month, :day, :hour, :min, :sec ].map do |segment| typecast_to_numeric(value.fetch(segment, now.send(segment)), :to_i) end end |