Module: DataMapper::Property::Typecast::Time
- Includes:
- Numeric
- Included in:
- Date, DateTime, DataMapper::Property::Time
- Defined in:
- lib/dm-core/property/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 24 25 26 27 28 29 |
# File 'lib/dm-core/property/typecast/time.rb', line 17 def extract_time(value) mash = if value.respond_to?(:to_mash) value.to_mash else DataMapper::Ext::Hash.to_mash(value) end now = ::Time.now [ :year, :month, :day, :hour, :min, :sec ].map do |segment| typecast_to_numeric(mash.fetch(segment, now.send(segment)), :to_i) end end |