lib/fixtury/store.rb in fixtury-0.1.0.beta2 vs lib/fixtury/store.rb in fixtury-0.1.0.rc1
- old
+ new
@@ -51,11 +51,11 @@
def clear_expired_references!
return unless ttl
references.delete_if do |name, ref|
- is_expired = ref_expired?(ref)
+ is_expired = ref_invalid?(ref)
log { "expiring #{name}" } if is_expired
is_expired
end
end
@@ -106,11 +106,11 @@
if ref&.holder?
raise ::Fixtury::Errors::CircularDependencyError, full_name
end
- if ref && auto_refresh_expired && ref_expired?(ref)
+ if ref && auto_refresh_expired && ref_invalid?(ref)
log { "refreshing #{full_name}" }
clear_ref(full_name)
ref = nil
end
@@ -152,13 +152,13 @@
def clear_ref(name)
references.delete(name)
end
- def ref_expired?(ref)
- return false unless ttl
+ def ref_invalid?(ref)
+ return true if ttl && ref.created_at < (Time.now.to_i - ttl)
- ref.created_at < (Time.now.to_i - ttl)
+ !locator.recognize?(ref.value)
end
def log(local_verbose = false, &block)
return unless verbose || local_verbose