Sha256: b9e23c7771188ebebf91b90abe9475e72f9b3188a9789c395eab72dfc26b0209

Contents?: true

Size: 862 Bytes

Versions: 6

Compression:

Stored size: 862 Bytes

Contents

class ExternalGroupUpdater < UpdateAgent
  self.resource = ExternalGroup
  
  def check_for_invalid_columns; end
  
  def compare
    groups = resource.find(:all)
    @data.each do |record|
      if !(group = groups.detect { |g| g.external_id == record['id'] })
        @create << record
      elsif group.name != record['name'] or group.category.to_s != record['category'].to_s
        @update << record
      end
    end
  end
  
  def push
    puts 'Updating remote end...'
    @create.each do |record|
      group = resource.new(:external_id => record['id'], :name => record['name'], :category => record['category'])
      group.save
    end
    @update.each do |record|
      group = resource.find(record['id'], :params => {:external_id => true})
      group.name = record['name']
      group.category = record['category']
      group.save
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
seven1m-onebody-updateagent-0.2.2 lib/updateagent/updaters/external_group_updater.rb
seven1m-onebody-updateagent-0.2.3 lib/updateagent/updaters/external_group_updater.rb
onebody-updateagent-0.4.3 lib/updateagent/updaters/external_group_updater.rb
onebody-updateagent-0.4.2 lib/updateagent/updaters/external_group_updater.rb
onebody-updateagent-0.4.1 lib/updateagent/updaters/external_group_updater.rb
onebody-updateagent-0.4.0 lib/updateagent/updaters/external_group_updater.rb