Implement ActionList::Entry#clear.
[kaya.git] / lib / games / validable.rb
blob9fc551f3f4f1dbd1d54c220b3155bb1694752833
1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 module Validable
9   attr_writer :valid
10   
11   def valid?
12     @valid
13   end
14   
15   def validated?
16     @valid != nil
17   end
18   
19   def validate
20     if validated?
21       valid?
22     else
23       self.valid = yield self
24     end
25   end
26 end