Sha256: c319256944cb82c6e8458dc30ac12947895321ddd87f27e62552a42c7a9a8650
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
# -*- encoding: utf-8 -*- require 'webgen/item_tracker' module Webgen class ItemTracker # This class is used to track changes to a node's meta information. # # Depending on what should be tracked, one needs to provide the following item: # # [node_alcn, nil] # Tracks changes to the whole meta information of the node, i.e. if any meta information value # changes, a change is detected. # # [node_alcn, key] # Tracks changes to a specific meta information key of the node. # # Here are some examples: # # website.ext.item_tracker.add(some_node, :node_meta_info, my_node.alcn) # first case # website.ext.item_tracker.add(some_node, :node_meta_info, my_node.alcn, 'title') # second case # class NodeMetaInfo CONTENT_MODIFICATION_KEY = 'modified_at' def initialize(website) #:nodoc: @website = website end def item_id(alcn, key = nil) #:nodoc: [alcn, key] end def item_data(alcn, key = nil) #:nodoc: mi = @website.tree[alcn].meta_info key.nil? ? (mi = mi.dup; mi.delete(CONTENT_MODIFICATION_KEY); mi) : mi[key].dup end def changed?(iid, old_data) #:nodoc: alcn, key = *iid @website.tree[alcn].nil? || item_data(alcn, key) != old_data end def node_referenced?(iid, mi, node_alcn) #:nodoc: iid.first == node_alcn end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
webgen-1.0.0.beta1 | lib/webgen/item_tracker/node_meta_info.rb |