Included Modules

Class Index [+]

Quicksearch

DataMapper::Property::Date

Public Instance Methods

typecast_hash_to_date(value) click to toggle source

Creates a Date instance from a Hash with keys :year, :month, :day

@param [Hash, #] value

  value to be typecast

@return [Date]

  Date constructed from hash

@api private

    # File lib/dm-core/property/date.rb, line 40
40:       def typecast_hash_to_date(value)
41:         ::Date.new(*extract_time(value)[0, 3])
42:       end
typecast_to_primitive(value) click to toggle source

Typecasts an arbitrary value to a Date Handles both Hashes and Date instances.

@param [Hash, #, #] value

  value to be typecast

@return [Date]

  Date constructed from value

@api private

    # File lib/dm-core/property/date.rb, line 19
19:       def typecast_to_primitive(value)
20:         if value.respond_to?(:to_date)
21:           value.to_date
22:         elsif value.is_a?(::Hash) || value.respond_to?(:to_mash)
23:           typecast_hash_to_date(value)
24:         else
25:           ::Date.parse(value.to_s)
26:         end
27:       rescue ArgumentError
28:         value
29:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.