Skip to content

Instantly share code, notes, and snippets.

@superlou
Created April 9, 2012 00:41
Show Gist options
  • Save superlou/2340561 to your computer and use it in GitHub Desktop.
Save superlou/2340561 to your computer and use it in GitHub Desktop.
Rules
class Rule < ActiveRecord::Base
* implements satisfied?
* implements message
* belongs_to a "ruleable" object (object you can apply a rule, to polymorphic)
class RoomMustHaveCapacityRule < Rule
* has an integer value "capacity"
* satisfied if rule is applied to a Room model who's seating capacity is >= the rule's capacity
* message indicates "success" or "failure by [how much]"
class RoomMustBeScheduleOnDate < Rule
* has an datetime value "date"
* satisfied if the rule is applied to a Room model that is booked on date
* message indicates "success" or "failure: room must be booked on [date]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment