Look into options['extract'] for checking the extraction type.

WebsiteAgent#extraction_type was private and uncallable, and may not
remain existent in future.
This commit is contained in:
Akinori MUSHA 2014-07-27 09:47:49 +09:00
parent fa0723ed8a
commit 70157dc687

View file

@ -1,7 +1,15 @@
class AdoptXpathInWebsiteAgent < ActiveRecord::Migration
class Agent < ActiveRecord::Base
include JSONSerializedField
json_serialize :options
end
def up
Agent.where(type: 'Agents::WebsiteAgent').each do |agent|
next if agent.extraction_type == 'json'
extract = agent.options['extract']
next unless extract.is_a?(Hash) && extract.all? { |name, detail|
detail.key?('xpath') || detail.key?('css')
}
agent.options_will_change!
agent.options['extract'].each { |name, extraction|