class Puppet::Relationship
This is Puppet's class for modeling edges in its configuration graph. It used to be a subclass of GRATR::Edge, but that class has weird hash overrides that dramatically slow down the graphing.
Attributes
callback[RW]
event[R]
source[RW]
target[RW]
Public Class Methods
from_data_hash(data)
click to toggle source
# File lib/puppet/relationship.rb 18 def self.from_data_hash(data) 19 source = data['source'] 20 target = data['target'] 21 22 args = {} 23 args[:event] = :"#{data['event']}" if data["event"] 24 args[:callback] = :"#{data['callback']}" if data["callback"] 25 26 new(source, target, args) 27 end
new(source, target, options = {})
click to toggle source
# File lib/puppet/relationship.rb 35 def initialize(source, target, options = {}) 36 @source, @target = source, target 37 38 options = (options || {}).inject({}) { |h,a| h[a[0].to_sym] = a[1]; h } 39 [:callback, :event].each do |option| 40 value = options[option] 41 send(option.to_s + "=", value) if value 42 end 43 end
Public Instance Methods
event=(event)
click to toggle source
# File lib/puppet/relationship.rb 29 def event=(event) 30 #TRANSLATORS 'NONE' should not be translated 31 raise ArgumentError, _("You must pass a callback for non-NONE events") if event != :NONE and ! callback 32 @event = event 33 end
inspect()
click to toggle source
# File lib/puppet/relationship.rb 68 def inspect 69 "{ #{source} => #{target} }" 70 end
label()
click to toggle source
# File lib/puppet/relationship.rb 57 def label 58 result = {} 59 result[:callback] = callback if callback 60 result[:event] = event if event 61 result 62 end
match?(event)
click to toggle source
Does the passed event match our event? This is where the meaning of :NONE comes from.
# File lib/puppet/relationship.rb 47 def match?(event) 48 if self.event.nil? or event == :NONE or self.event == :NONE 49 return false 50 elsif self.event == :ALL_EVENTS or event == self.event 51 return true 52 else 53 return false 54 end 55 end
ref()
click to toggle source
# File lib/puppet/relationship.rb 64 def ref 65 "#{source} => #{target}" 66 end
to_data_hash()
click to toggle source
# File lib/puppet/relationship.rb 72 def to_data_hash 73 data = { 74 'source' => source.to_s, 75 'target' => target.to_s 76 } 77 data['event'] = event.to_s unless event.nil? 78 data['callback'] = callback.to_s unless callback.nil? 79 data 80 end
to_s()
click to toggle source
# File lib/puppet/relationship.rb 82 def to_s 83 ref 84 end