Class: PG::TextEncoder::Date

Inherits:
SimpleEncoder show all
Defined in:
lib/pg/text_encoder/date.rb

Overview

This is a encoder class for conversion of Ruby Date values to PostgreSQL date type.

Constant Summary

Constants inherited from Coder

Coder::FORMAT_ERROR_MASK, Coder::FORMAT_ERROR_TO_PARTIAL, Coder::FORMAT_ERROR_TO_RAISE, Coder::FORMAT_ERROR_TO_STRING, Coder::TIMESTAMP_APP_LOCAL, Coder::TIMESTAMP_APP_UTC, Coder::TIMESTAMP_DB_LOCAL, Coder::TIMESTAMP_DB_UTC

Instance Attribute Summary

Attributes inherited from Coder

#name

Instance Method Summary collapse

Methods inherited from Coder

#==, #dup, #flags, #flags=, #format, #format=, #initialize, #inspect, #inspect_short, #marshal_dump, #marshal_load, #oid, #oid=, #to_h

Constructor Details

This class inherits a constructor from PG::Coder

Instance Method Details

#encode(value) ⇒ Object



8
9
10
# File 'lib/pg/text_encoder/date.rb', line 8

def encode(value)
	value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d") : value
end