lib/junos-ez/provider.rb
## ----------------------------------------------------------------
## 'create' will build a new object, but does not write the 
## contents back to the device.  The caller can chain the
## write! method if desired  Alternative, the caller
## can use 'create!' which does write to the device.
## ----------------------------------------------------------------

'create' will build a new object, but does not write the
contents back to the device.  The caller can chain the
write. method if desired  Alternative, the caller
can use 'create!' which does write to the device.
' create ' will build a new object but does not write the contents back to the device . The caller can chain the write . method if desired Alternative the caller can use ' create! ' which does write to the device .
def create( name = nil, prop_hash = {} )
    raise ArgumentError, "Not called by provider!" unless is_provider?
    newbie = self.select( name )    
    if prop_hash[:_exist]
      raise ArgumentError,  name_decorated(name) + " already exists" if newbie.exists? 
    end
    prop_hash.each{ |k,v| newbie[k] = v } unless prop_hash.empty?
    newbie[:_exist] = true
    newbie[:_active] ||= true    
    yield( newbie ) if block_given?   
    return newbie    
  end
def create ( name = nil , prop_hash = { } ) raise ArgumentError , "Not called by provider!" unless is_provider? newbie = self . select ( name ) if prop_hash [ :_exist ] raise ArgumentError , name_decorated ( name ) + " already exists" if newbie . exists? end prop_hash . each { | k , v | newbie [ k ] = v } unless prop_hash . empty? newbie [ :_exist ] = true newbie [ :_active ] ||= true yield ( newbie ) if block_given? return newbie end
'create' will build a new object, but does not write the
contents back to the device.
' create ' will build a new object but does not write the contents back to the device .
## if this is an existing object, then we shouldn't 
 ## allow the caller to create something.
 ## if we're here, then we're creating an entirely new
 ## instance of this object.  We should check to see if
 ## it first exists, eh?  So allow the caller to specify
 ## if they want an exception if it already exists; overloading
 ## the use of the prop_hash[:_exist], yo!
 ## default mark the newly created object as should exist and should
 ## be active (if not already set)
 ## if a block is provided, then pass the block the new object
 ## the caller is then expected to set the properies
 ## return the new object    

name
<not_specific>
prop_hash
<not_specific>