Class: Kudzu::Adapter::ActiveRecord::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/kudzu/adapter/active_record/repository.rb

Instance Method Summary collapse

Instance Method Details

#delete(page) ⇒ Object



18
19
20
# File 'lib/kudzu/adapter/active_record/repository.rb', line 18

def delete(page)
  page.destroy if page
end

#find_by_url(url) ⇒ Object



7
8
9
# File 'lib/kudzu/adapter/active_record/repository.rb', line 7

def find_by_url(url)
  Page.find_or_initialize_by(url: url)
end

#register(page) ⇒ Object



11
12
13
14
15
16
# File 'lib/kudzu/adapter/active_record/repository.rb', line 11

def register(page)
  ActiveRecord::Base.transaction do
    page.save
    save_chunks(page) if page.body
  end
end