This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/lib/orbit_model/time_frame.rb

32 lines
592 B
Ruby
Raw Normal View History

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