module DataAnon
  module Strategy
    class Whitelist < DataAnon::Strategy::Base

      def self.whitelist?
        true
      end

      def process_record(index, record)
        dest_record_map = {}
        record.attributes.each do |field_name, field_value|
          unless field_value.nil? || is_primary_key?(field_name)
            field = DataAnon::Core::Field.new(field_name, field_value, index, record, @name)
            field_strategy = @fields[field_name.downcase] || default_strategy(field_name)
            dest_record_map[field_name] = field_strategy.anonymize(field)
          end
        end
        dest_record = dest_table.new dest_record_map
        @primary_keys.each do |key|
          dest_record[key] = record[key]
        end
        dest_record.save!
      end


    end
  end
end

module DataAnon
  module Strategy
    class Whitelist < DataAnon::Strategy::Base

      def self.whitelist?
        true
      end

      def process_record(index, record)
        dest_record_map = {}
        record.attributes.each do |field_name, field_value|
          unless field_value.nil? || is_primary_key?(field_name)
            field = DataAnon::Core::Field.new(field_name, field_value, index, record, @name)
            field_strategy = @fields[field_name.downcase] || default_strategy(field_name)
            dest_record_map[field_name] = field_strategy.anonymize(field)
          end
        end
        dest_record = dest_table.new dest_record_map
        dest_record.assign_attributes(dest_record_map, without_protection: true)
        @primary_keys.each do |key|
          dest_record[key] = record[key]
        end
        dest_record.save!
      end


    end
  end
end

Fix for rails mass-assignment protection
Fix for rails mass-assignment protection

In rails 3.2.8, mass assignment can mean that the ActiveModel class
doesn't support mass assignment. This change ignores any such
protection and assumes it's your own data and you know what you're
doing with it.
