It's usually better to use "confine" statements inside the Facter block. Such if/else cases will be avaluated only at loading time when facter is used as a library (as opposed to used as an executable). Example:

    Facter.add('expressservicecode') do 
      confine :id => 'root'
      confine :is_virtual => false
... etc