module OrbitModel module TimeFrame def self.included(base) base.class_eval do field :postdate , :type => DateTime field :deadline , :type => DateTime before_save :check_deadline send :include, InstanceMethods end end module InstanceMethods def is_expired? Date.today > self.deadline ? true : false rescue false end private def check_deadline if(!self.deadline.nil? and (self.deadline < self.postdate )) self.deadline = nil end end end end end