title: Access type params from puppet provider
body: <p>I'm trying to create a perforce custom type <em>devtrack</em> but am stuck in the prefetch stage. There I am trying to use my instances class method to find the correct provider </p>
  
  <pre><code>def self.prefetch(resources)
      instances.each do |prov|
          if resource = resources[prov.name]
              resource.provider = prov
          end
      end
  end
  </code></pre>
  
  <p>and in the instances class method I try to find all clients on the current host by using the command</p>
  
  <blockquote>
    <p>p4 workspaces -u </p>
  </blockquote>
  
  <p>using the below code </p>
  
  <pre><code>def self.get_list_of_workspaces_on_host(host)       
      ws_strs = p4(['workspaces', '-u', &lt;USERNAME&gt;]).split("\n")
      ws_strs.select { |str| str.include?(host) }.map{ |ws| ws.split[1] }
  end
  
  def self.get_workspace_properties(ws)
      md = /^(\w*)_.*_(main|\d{2})_managed$/.match(ws)
      ws_props = {}
      ws_props[:ensure]    = :present
      ...
      ws_props
  end
  
  def self.instances
      host = `hostname`.strip
      get_list_of_workspaces_on_host(host).collect do |ws|
          ws_props = get_workspace_properties(ws)
          new(ws_props)
      end
  end
  </code></pre>
  
  <p>and the p4 command is defined like</p>
  
  <pre><code>has_command(:p4, "/usr/bin/p4") do
      environment :P4PORT =&gt; &lt;PERFORCE SERVER&gt;, :P4USER =&gt; &lt;USERNAME&gt;
  end
  </code></pre>
  
  <p>The problem I have is that for any p4 command to work I need to access the server, this is specified in the type </p>
  
  <pre><code>devtrack { '36': source  =&gt; '&lt;PERFORCE SERVER&gt;'}
  </code></pre>
  
  <p>but how can I access this value from prefetch? The problem beeing that prefetch is a class method and thus can not access the <strong>@properties_hash</strong> or the <strong>resource</strong> hash. Is there a way to get around this? Am I designing this completely wrong?</p>