Module: Para::SeoTools::Skeleton
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/para/seo_tools/skeleton.rb,
lib/para/seo_tools/skeleton/page.rb,
lib/para/seo_tools/skeleton/site.rb,
lib/para/seo_tools/skeleton/worker.rb
Defined Under Namespace
Classes: Page, Site, Worker
Class Method Summary
collapse
Class Method Details
.build ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/para/seo_tools/skeleton.rb', line 33
def self.build
return if migrating?
return unless ActiveRecord::Base.connection.table_exists?(Para::SeoTools::Page.table_name)
log " * Building app skeleton pages ..."
self.site = Skeleton::Site.new(enable_logging: enable_logging)
site.instance_exec(&config)
ActiveRecord::Base.transaction do
site.save
destroy_deleted_pages!
end
end
|
.destroy_deleted_pages! ⇒ Object
56
57
58
59
60
|
# File 'lib/para/seo_tools/skeleton.rb', line 56
def self.destroy_deleted_pages!
pages = Para::SeoTools::Page.where.not(id: site.saved_pages_ids)
log " * Destroying old pages ..."
pages.delete_all
end
|
.draw(lazy: false, &block) ⇒ Object
28
29
30
31
|
# File 'lib/para/seo_tools/skeleton.rb', line 28
def self.draw(lazy: false, &block)
self.config = block
build unless lazy
end
|
.load ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/para/seo_tools/skeleton.rb', line 19
def self.load
Rails.application.reload_routes!
skeleton_path = Rails.root.join('config', 'skeleton.rb')
require skeleton_path if File.exists?(skeleton_path)
end
|
.log(message) ⇒ Object
Log messages when you’re not in rails
64
65
66
|
# File 'lib/para/seo_tools/skeleton.rb', line 64
def self.log(message)
Rails.logger.info(message) if enable_logging || !$0.end_with?('rails')
end
|
.migrating? ⇒ Boolean
52
53
54
|
# File 'lib/para/seo_tools/skeleton.rb', line 52
def self.migrating?
ActiveRecord::Migrator.needs_migration?
end
|
.with_logging(&block) ⇒ Object
12
13
14
15
16
17
|
# File 'lib/para/seo_tools/skeleton.rb', line 12
def self.with_logging(&block)
self.enable_logging = true
block.call
ensure
self.enable_logging = false
end
|