Method: Locd::Agent::System.class_for

Defined in:
lib/locd/agent/system.rb

.class_for(plist) ⇒ Class<Locd::Agent>?

Find the concrete Locd::Agent subclass (that has mixed in Locd::Agent::System) for a property list.

Parameters:

  • plist (Hash<String, Object>)

Returns:

  • (Class<Locd::Agent>)

    If the plist is for one of classes, returns that class.

  • (nil)

    If the plist is:

    1. Not a system plist (see plist?)

    2. If none of classes claim it (via their .plist? method).

      Though, really, this one shouldn't happen except in weird version switching situations maybe or something.



82
83
84
85
86
# File 'lib/locd/agent/system.rb', line 82

def self.class_for plist
  return nil unless plist?( plist )
  
  classes.to_a.find_bounded( max: 1 ) { |cls| cls.plist? plist }.first
end