Class: NicInfo::ResponseObjSet

Inherits:
Object
  • Object
show all
Defined in:
lib/nicinfo/common_json.rb

Overview

for keeping track of objects to display

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ResponseObjSet

Returns a new instance of ResponseObjSet.



235
236
237
238
239
240
# File 'lib/nicinfo/common_json.rb', line 235

def initialize config
  @config = config
  @arr = Array.new #for keeping track of insertion order
  @set = Hash.new
  @self_links = Hash.new
end

Instance Method Details

#add(respObj) ⇒ Object



242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/nicinfo/common_json.rb', line 242

def add respObj
  if respObj.instance_of? Array
    respObj.each do |obj|
      add obj
    end
  else
    if !@set[ respObj.get_cn ]
      @set[ respObj.get_cn ] = respObj
      @arr << respObj
      self_link = NicInfo.get_self_link( NicInfo.get_links( respObj.objectclass, @config ) )
      @self_links[ self_link ] = respObj if self_link
    end
  end
end

#associateEntities(entities) ⇒ Object



271
272
273
274
275
276
277
278
279
# File 'lib/nicinfo/common_json.rb', line 271

def associateEntities entities
  entities.each do |entity|
    associateEntities entity.entities if !entity.entities.empty?
    entity.asEvents.each do |asEvent|
      asEvent.entity_cn = entity.get_cn
      associateEventActor asEvent
    end
  end if entities
end

#associateEventActor(eventActor) ⇒ Object



263
264
265
266
267
268
269
# File 'lib/nicinfo/common_json.rb', line 263

def associateEventActor eventActor
  return if !eventActor or !eventActor.related
  associate = @self_links[ eventActor.related ]
  if associate
    associate.asEventActors << eventActor
  end
end

#displayObject



257
258
259
260
261
# File 'lib/nicinfo/common_json.rb', line 257

def display
  @arr.each do |object|
    object.display
  end
end