Module: SitemapNotifier::ActiveRecord

Defined in:
lib/sitemap_notifier/active_record.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/sitemap_notifier/active_record.rb', line 5

def self.included(base)
  [:create, :update, :destroy].each do |action|
    base.send("after_#{action}") do
      notify_sitemap(action)
    end
  end
end

Instance Method Details

#notify_sitemap(action) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/sitemap_notifier/active_record.rb', line 13

def notify_sitemap(action)
  notifier = SitemapNotifier::Notifier
  
  if (notifier.notify_of_changes_to?(self.class, action)) && notify_sitemap?
    notifier.run(sitemap_url)
  end
end

#notify_sitemap?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/sitemap_notifier/active_record.rb', line 21

def notify_sitemap?
  true
end

#sitemap_urlObject



25
26
27
# File 'lib/sitemap_notifier/active_record.rb', line 25

def sitemap_url
  SitemapNotifier::Notifier.sitemap_url
end