class Feed2Email::Migrate::FeedsImportMigration

Public Instance Methods

apply() click to toggle source
# File lib/feed2email/migrate/feeds_import_migration.rb, line 7
def apply
  applicable? && migrate
end

Private Instance Methods

applicable?() click to toggle source
Calls superclass method
# File lib/feed2email/migrate/feeds_import_migration.rb, line 13
def applicable?
  super && table_empty? && valid_data?
end
filename() click to toggle source
# File lib/feed2email/migrate/feeds_import_migration.rb, line 17
def filename
  'feeds.yml'
end
migrate() click to toggle source
# File lib/feed2email/migrate/feeds_import_migration.rb, line 21
def migrate
  data.each do |feed|
    Feed.create(
      uri:               feed[:uri],
      enabled:           feed[:enabled],
      etag:              feed[:etag],
      last_modified:     feed[:last_modified],
      last_processed_at: Time.now
    )
  end
end
table_empty?() click to toggle source
# File lib/feed2email/migrate/feeds_import_migration.rb, line 33
def table_empty?
  Feed.empty?
end
valid_data?() click to toggle source
# File lib/feed2email/migrate/feeds_import_migration.rb, line 37
def valid_data?
  data.is_a?(Array) && data.all? {|d| d.is_a?(Hash) && d.has_key?(:uri) }
end