Class: Milkshake::Validator
- Inherits:
-
Object
- Object
- Milkshake::Validator
- Defined in:
- lib/milkshake/validator.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#link_time ⇒ Object
readonly
Returns the value of attribute link_time.
Instance Method Summary collapse
- #current_link_time ⇒ Object
-
#initialize(cache) ⇒ Validator
constructor
A new instance of Validator.
- #persist! ⇒ Object
- #relink? ⇒ Boolean
Constructor Details
#initialize(cache) ⇒ Validator
Returns a new instance of Validator.
9 10 11 12 13 14 |
# File 'lib/milkshake/validator.rb', line 9 def initialize(cache) @cache = cache @link_time = @cache.key('link.time') @cache.reset! if relink? end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
7 8 9 |
# File 'lib/milkshake/validator.rb', line 7 def cache @cache end |
#link_time ⇒ Object (readonly)
Returns the value of attribute link_time.
7 8 9 |
# File 'lib/milkshake/validator.rb', line 7 def link_time @link_time end |
Instance Method Details
#current_link_time ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/milkshake/validator.rb', line 16 def current_link_time return @current_link_time unless @current_link_time.nil? path = File.join(RAILS_ROOT, 'tmp', 'relink.txt') if File.file?(path) @current_link_time = File.mtime(path) else @current_link_time = Time.now end @current_link_time end |
#persist! ⇒ Object
33 34 35 |
# File 'lib/milkshake/validator.rb', line 33 def persist! @cache['link.time'] = Time.now end |
#relink? ⇒ Boolean
29 30 31 |
# File 'lib/milkshake/validator.rb', line 29 def relink? (link_time.nil?) or (current_link_time and link_time and current_link_time > link_time) end |