class ParamsReady::Value::DateCoder
Public Class Methods
coerce(input, _)
click to toggle source
# File lib/params_ready/value/coder.rb, line 168 def self.coerce(input, _) return nil if input.nil? || input == '' if input.is_a?(Numeric) Time.at(input).to_date elsif input.is_a?(String) Date.parse(input) elsif input.respond_to?(:to_date) input.to_date else raise ParamsReadyError, "Unimplemented for type #{input.class.name}" end end
format(value, format)
click to toggle source
# File lib/params_ready/value/coder.rb, line 181 def self.format(value, format) value.to_s end