fnando / recurrence

A simple library that handles recurring events.
http://github.com/fnando/recurrence
MIT License
565 stars 54 forks source link

Marshalling and Unmarshalling #24

Open IvanShamatov opened 8 years ago

IvanShamatov commented 8 years ago

Hello @fnando Thanks for creating this really nice gem to use recurrence. I've spent lots of time trying to create same logic in my project working from database abilities and not recurrence nature of my events. But this gem is what I need. Though I still need to store initialization information in my database. And for now, I suppose really simple solution is just make store initial string in json. But what I'm thinking about are some features most people can look for:

I'm really interested in some of these features, though it might be not the best place for that. So what do you think about that?

fnando commented 8 years ago

I usually keep some columns (or a JSONB column in PostgreSQL) with all the values I need. I don't think specific helpers for this are required because it's fairly simple. If you're going the JSON column route, you can easily store each of the initialization values in its own key.

Then you can have a method/class that loads this information and initializes a new Recurrence object.

Again, since the logic is really simple, I don't think it makes sense trying to create abstractions.

IvanShamatov commented 8 years ago

Yes, sounds reasonable. And what you think about having method like to_cron and to_recurrent. This possibly can give some selecting query abilities? I didn't benchmark it, just guesses...

RedaBenh commented 8 years ago

+1 for to_cron method