Class: Nanoc::Core::OutdatednessRules::AttributesModified
- Inherits:
-
Nanoc::Core::OutdatednessRule
- Object
- Nanoc::Core::OutdatednessRule
- Nanoc::Core::OutdatednessRules::AttributesModified
- Includes:
- ContractsSupport
- Defined in:
- lib/nanoc/core/outdatedness_rules/attributes_modified.rb
Instance Method Summary collapse
Methods included from ContractsSupport
enabled?, included, setup_once, warn_about_performance
Methods inherited from Nanoc::Core::OutdatednessRule
affects_attributes?, affects_compiled_content?, affects_path?, affects_props, affects_raw_content?, #call, #inspect
Instance Method Details
#apply(obj, basic_outdatedness_checker) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/nanoc/core/outdatedness_rules/attributes_modified.rb', line 18 def apply(obj, basic_outdatedness_checker) boc = basic_outdatedness_checker case obj when Nanoc::Core::ItemRep apply(obj.item, boc) when Nanoc::Core::Item, Nanoc::Core::Layout, Nanoc::Core::Configuration if boc.checksum_store[obj] == boc.checksums.checksum_for(obj) return nil end old_checksums = boc.checksum_store.attributes_checksum_for(obj) unless old_checksums return Nanoc::Core::OutdatednessReasons::AttributesModified .new(true) end new_checksums = boc.checksums.attributes_checksum_for(obj) attributes = Set.new(old_checksums.keys) + Set.new(new_checksums.keys) changed_attributes = attributes.reject { |a| old_checksums[a] == new_checksums[a] } unless changed_attributes.empty? Nanoc::Core::OutdatednessReasons::AttributesModified .new(changed_attributes) end else raise ArgumentError end end |