ice-cube-ruby / ice_cube

Ruby Date Recurrence Library - Allows easy creation of recurrence rules and fast querying
MIT License
2.41k stars 358 forks source link

How to handle recurring rule with some modification in main Event Object #426

Closed uzaif313 closed 7 years ago

uzaif313 commented 7 years ago

Hi @avit,

It's not actual issue but i want to know what is the best way to handle following scenario Think of Scheduling apply on Recipe -> I have Recipe event schedule which occurs on every Monday with recipe Taco Salad -> Now i want to modify recipe for specific Monday i need Macaroni and Cheese in recipe

Please let me know what is elegant way to handle above scenario

jorroll commented 7 years ago

Is this interpretation of your question correct:

  1. You have an event called "Taco Salad" which occurs every Monday
  2. For a specific Monday, you want to rename the event to "Macaroni & Cheese"

?

uzaif313 commented 7 years ago

@thefliik yes i need this kind implementation

dsdshcym commented 7 years ago

@uzaif313 If what you need is to update a specific Monday, instead of every Monday, then I think it can be achieved by:

  1. Use add_exception_time to exclude that specific Monday for this event
  2. Create a non-recurrent event for this Monday named "Macaroni & Cheese"
uzaif313 commented 7 years ago

@dsdshcym thanks for help

I thought this solution but we don't need to create another record for recipe if any other solution please let me know

jorroll commented 7 years ago

So, in general, I don't think this is a question about this library. Someone correct me if I'm wrong, but this library only deals with recurrence rules. Giving events a single name is outside the scope of this library, let alone giving them multiple names. You'll need to write custom logic to handle this in your app. I imagine the "best" implementation will be heavily dependent on the structure of the rest of your app.

avit commented 7 years ago

Adding "names" and other data about schedules and events is outside the scope of this library.

Only your own application can know how to best handle this, so it's up to you to attach a schedule to your own objects.