lib/puppet/provider/macauthdb/default.rb
def sql_insert_or_udpate_rules(dbconn, op, data)
    statement = case op
    when :insert
      columns      = data.keys.collect { |x| "`#{x}`" }.join(',')
      placeholders = (['?'] * data.values.size).join(',')
      %Q{INSERT INTO rules (#{columns}) VALUES (#{placeholders})}
    else
      data.delete_if { |k| %w{name created}.member?(k) }
      columns = data.keys.map { |k| "`#{k}` = ?" }
      %Q{UPDATE rules SET #{columns.join(', ')} WHERE name = '#{name}'}
    end
    self.class.exec_sql_statement(dbconn, statement, data.values)
    sql_get_rule dbconn, name
  end
# Returns the updated rule as a Hash
Returns the updated rule as a Hash
Returns the updated rule as a Hash
def sql_insert_or_udpate_rules(dbconn, op, data)
    statement = case op
    when :insert
      columns      = data.keys.collect { |x| "`#{x}`" }.join(',')
      placeholders = (['?'] * data.values.size).join(',')
      %Q{INSERT INTO rules (#{columns}) VALUES (#{placeholders})}
    else
      data.delete_if { |k| %w{name created}.member?(k) }
      columns = data.keys.map { |k| "`#{k}` = ?" }
      %Q{UPDATE rules SET #{columns.join(', ')} WHERE name = '#{name}'}
    end
    self.class.exec_sql_statement(dbconn, statement, data.values)
    sql_get_rule dbconn, name
  end
def sql_insert_or_udpate_rules ( dbconn , op , data ) statement = case op when :insert columns = data . keys . collect { | x | "`#{x}`" } . join ( ',' ) placeholders = ( [ '?' ] * data . values . size ) . join ( ',' ) %Q{INSERT INTO rules (#{columns}) VALUES (#{placeholders})} else data . delete_if { | k | %w{ name created } . member? ( k ) } columns = data . keys . map { | k | "`#{k}` = ?" } %Q{UPDATE rules SET #{columns.join(', ')} WHERE name = '#{name}'} end self . class . exec_sql_statement ( dbconn , statement , data . values ) sql_get_rule dbconn , name end
Returns the updated rule as a Hash
Returns the updated rule as a Hash
dbconn
op
data