lib/hanko/fingerprint.rb in hanko-0.1.3 vs lib/hanko/fingerprint.rb in hanko-0.1.4

- old
+ new

@@ -1,14 +1,20 @@ require 'digest/sha2' module Hanko class Fingerprint class << self - attr_writer :digest_class + attr_writer :digest_class, :cachable def pon(assets_dir, source) - cached_pon[source] ||= generate_pon(assets_dir, source) + fingerprint = generate_pon(assets_dir, source) + + if cachable? + cached_pon[source] ||= fingerprint + else + fingerprint + end end def digest_class=(klass) @cached_pon = {} @digest_class = klass @@ -29,9 +35,13 @@ digest_class.file(path).hexdigest end def digest_class @digest_class || ::Digest::SHA256 + end + + def cachable? + @cachable != false end end end end