Module: ArcWeld::Relationships::InZone
- Defined in:
- lib/arc_weld/relationships/in_zone.rb
Instance Method Summary collapse
- #auto_zone(*zones) ⇒ Object
- #in_zone=(zone) ⇒ Object
- #in_zone_relationship ⇒ Object
- #parent_ref_from_zone(zone) ⇒ Object
- #set_zone(tgt_zone) ⇒ Object
Instance Method Details
#auto_zone(*zones) ⇒ Object
10 11 12 13 |
# File 'lib/arc_weld/relationships/in_zone.rb', line 10 def auto_zone(*zones) my_zone = zones.find {|z| z.contains?(self.address)} self.set_zone(my_zone) unless my_zone.nil? end |
#in_zone=(zone) ⇒ Object
36 37 38 |
# File 'lib/arc_weld/relationships/in_zone.rb', line 36 def in_zone=(zone) self.set_zone(zone) end |
#in_zone_relationship ⇒ Object
4 5 6 7 8 |
# File 'lib/arc_weld/relationships/in_zone.rb', line 4 def in_zone_relationship unless in_zone.nil? { 'inZone' => { 'list!' => in_zone.ref.render } } end end |
#parent_ref_from_zone(zone) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/arc_weld/relationships/in_zone.rb', line 15 def parent_ref_from_zone(zone) unless zone.parent_ref == ArcWeld::Zone.toplevel asset_group_uri = zone.ref_uri.gsub('All Zones', 'All Assets') ArcWeld::Reference.new( uri: asset_group_uri, externalID: OpenSSL::Digest::MD5.base64digest(asset_group_uri), type: 'Group' ) end end |
#set_zone(tgt_zone) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/arc_weld/relationships/in_zone.rb', line 25 def set_zone(tgt_zone) if tgt_zone.contains?(address) self.staticAddressing = tgt_zone.staticAddressing self.has_location = tgt_zone.has_location self.in_network = tgt_zone.in_network tgt_ref = parent_ref_from_zone(tgt_zone) self.parent_ref = tgt_ref unless tgt_ref.nil? @in_zone = tgt_zone end end |