Class: Puppet::Relationship Private
- Includes:
- Network::FormatSupport, Util::PsychSupport
- Defined in:
- lib/puppet/relationship.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
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.
Instance Attribute Summary collapse
- #callback ⇒ Object private
- #event ⇒ Object private
- #source ⇒ Object private
- #target ⇒ Object private
Class Method Summary collapse
- .from_data_hash(data) ⇒ Object private
Instance Method Summary collapse
-
#initialize(source, target, options = {}) ⇒ Relationship
constructor
private
A new instance of Relationship.
- #inspect ⇒ Object private
- #label ⇒ Object private
-
#match?(event) ⇒ Boolean
private
Does the passed event match our event? This is where the meaning of :NONE comes from.
- #ref ⇒ Object private
- #to_data_hash ⇒ Object private
- #to_s ⇒ Object private
Methods included from Util::PsychSupport
Methods included from Network::FormatSupport
included, #mime, #render, #support_format?, #to_json, #to_msgpack, #to_pson
Constructor Details
#initialize(source, target, options = {}) ⇒ Relationship
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Relationship.
34 35 36 37 38 39 40 41 42 |
# File 'lib/puppet/relationship.rb', line 34 def initialize(source, target, = {}) @source, @target = source, target = ( || {}).inject({}) { |h,a| h[a[0].to_sym] = a[1]; h } [:callback, :event].each do |option| value = [option] send(option.to_s + "=", value) if value end end |
Instance Attribute Details
#callback ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/puppet/relationship.rb', line 13 def callback @callback end |
#event ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/puppet/relationship.rb', line 15 def event @event end |
#source ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/puppet/relationship.rb', line 13 def source @source end |
#target ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/puppet/relationship.rb', line 13 def target @target end |
Class Method Details
.from_data_hash(data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/puppet/relationship.rb', line 17 def self.from_data_hash(data) source = data['source'] target = data['target'] args = {} args[:event] = :"#{data['event']}" if data["event"] args[:callback] = :"#{data['callback']}" if data["callback"] new(source, target, args) end |
Instance Method Details
#inspect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
67 68 69 |
# File 'lib/puppet/relationship.rb', line 67 def inspect "{ #{source} => #{target} }" end |
#label ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 59 60 61 |
# File 'lib/puppet/relationship.rb', line 56 def label result = {} result[:callback] = callback if callback result[:event] = event if event result end |
#match?(event) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Does the passed event match our event? This is where the meaning of :NONE comes from.
46 47 48 49 50 51 52 53 54 |
# File 'lib/puppet/relationship.rb', line 46 def match?(event) if self.event.nil? or event == :NONE or self.event == :NONE return false elsif self.event == :ALL_EVENTS or event == self.event return true else return false end end |
#ref ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 |
# File 'lib/puppet/relationship.rb', line 63 def ref "#{source} => #{target}" end |
#to_data_hash ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
71 72 73 74 75 76 77 78 79 |
# File 'lib/puppet/relationship.rb', line 71 def to_data_hash data = { 'source' => source.to_s, 'target' => target.to_s } data['event'] = event.to_s unless event.nil? data['callback'] = callback.to_s unless callback.nil? data end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
81 82 83 |
# File 'lib/puppet/relationship.rb', line 81 def to_s ref end |