jgaskins / perpetuity-postgres

Postgres adapter for Perpetuity
MIT License
10 stars 7 forks source link

Add mappings for Date class #11

Open jgaskins opened 10 years ago

acook commented 10 years ago

Would it be useful to use Coercible to help with this?

jgaskins commented 10 years ago

I've been rolling everything in this gem, but that's probably a good idea. :-) I've been wondering if some of this stuff could be punted to gems because I know I've made some dumb decisions in some places.

If Coercible is a good use case for this, I'd like to use it for all of the type casts. I'll check it out.

acook commented 10 years ago

AFAIK Coercible is ready to go, and its being developed by Solnic and the other ROM guys, so I thought it might be good to spike out if it'll work well for your use cases.

Are you doing all of your object mappings in serializer or am I looking in the wrong place?

jgaskins commented 10 years ago

The Postgres::Table::Attribute class is where things get mapped between Ruby and PostgreSQL types. You'll notice it's a big if chain. I want to remove that VARCHAR because there is no reason to use it in Postgres, which will let us remove all actual logic from that and just use a Hash lookup or something.

jgaskins commented 10 years ago

Oh, I just realized, that only shows the mappings from Ruby to Postgres types. The reverse mappings are in Serializer#unserialize_attribute. It's ugly and I want to refactor it out into a single place.

acook commented 10 years ago

Oh yeah I was looking in the completely wrong place.