Class: Plist4r::PlistType::Launchd::Sockets

Defined in:
lib/plist4r/plist_type/launchd.rb

Classes

Instance Methods

Methods inherited from Plist4r::ArrayDict

#hash, #initialize, #select, #select_all, #to_hash, #unselect, #unselect_all

Methods included from Plist4r::DataMethods

#_respond_to?, #method_missing, #set_or_return, #set_or_return_of_type, #validate_value

Constant Summary

Constants included from Plist4r::DataMethods

ClassesForKeyType, ValidKeys, ValidKeysTemplate

Constructor Details

This class inherits a constructor from Plist4r::ArrayDict

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Plist4r::DataMethods

Instance Method Details

- (Object) add_socket(plicity, key, index = nil, &blk)



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
# File 'lib/plist4r/plist_type/launchd.rb', line 471

def add_socket plicity, key, index=nil, &blk
  select_all
  if plicity == :implicit
    if index && @orig[key].class != Array
      raise "Implicit \"Listeners\" socket already exists, and is of a different type (not array of hashes). Override with: socket \"Listeners\" #{index} &blk"
    elsif @orig[key]
      raise "Implicit \"Listeners\" socket already exists, value: #{orig[key]}. Override with: socket \"Listeners\" &blk"
    end
  end
  if index
    add_socket_to_array key, index, &blk
  else
    add_socket_to_dictionary key, &blk
  end
end

- (Object) add_socket_to_array(key, index, &blk)



465
466
467
468
469
# File 'lib/plist4r/plist_type/launchd.rb', line 465

def add_socket_to_array key, index, &blk
  @orig[key] = [] unless @orig[key].class == Array
  @hash[key] ||= []
  @hash[key][index] = Sockets::Socket.new(@orig[key],index,&blk).to_hash
end

- (Object) add_socket_to_dictionary(key, &blk)



461
462
463
# File 'lib/plist4r/plist_type/launchd.rb', line 461

def add_socket_to_dictionary key, &blk
  @hash[key] = Sockets::Socket.new(@hash[key],&blk).to_hash
end