Last active
August 29, 2015 13:58
-
-
Save tusharmath/9931602 to your computer and use it in GitHub Desktop.
A solution to resolve awfully customized event scheduling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IEvent | |
constructor: -> | |
@_rules = [] | |
set_description: (@description) -> | |
is_it_on: (date) -> | |
sorted_rules = @_rules | |
for rule in sorted_rules | |
if rule.execute date is yes | |
true | |
false | |
add_schedule_rule: (IRule) -> #Adds a schedule | |
reorder_rule_collection: (FinalOrderMap) -> | |
serialize: -> #creates an ob with evnt description and serialized rules. | |
class IRuleInitParams | |
class IRuleExecuteParams | |
class IRule | |
constructor: (IRuleInitParams) -> | |
clone: () -> #returns a clone of the rule | |
execute: (IRuleExecuteParams) -> | |
serialize: -> {rule_name, rule_executeparams} | |
class Daily extends IRule | |
#Contains all the rules | |
class RuleContainer | |
constructor: -> | |
@_rule_collection = [] | |
register_container: (name, schedule_rule) -> | |
@_rule_collection.push {name, schedule_rule} | |
fetch_container: (name) -> @_rule_collection.where item -> item.name is name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment