Class: ExternalGroupUpdater
- Inherits:
-
UpdateAgent
- Object
- UpdateAgent
- ExternalGroupUpdater
- Defined in:
- lib/updateagent/updaters/external_group_updater.rb
Instance Attribute Summary
Attributes inherited from UpdateAgent
#attributes, #create, #data, #update
Instance Method Summary collapse
Methods inherited from UpdateAgent
#confirm, #data_by_id, #has_work?, #ids, #initialize, #legacy_ids, #present, #present_record, #read_from_file, #resource
Constructor Details
This class inherits a constructor from UpdateAgent
Instance Method Details
#check_for_invalid_columns ⇒ Object
4 |
# File 'lib/updateagent/updaters/external_group_updater.rb', line 4 def check_for_invalid_columns; end |
#compare ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/updateagent/updaters/external_group_updater.rb', line 6 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 |
#push ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/updateagent/updaters/external_group_updater.rb', line 17 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 |