Class: Bridgetown::Builder
Overview
Superclass for a website’s SiteBuilder abstract class
Instance Attribute Summary
#config, #functions, #name, #site
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize, plugin_registrations
#add_resource, #define_resource_method, #permalink_placeholder, #placeholder_processors, #resource
#filters, #filters_context, #liquid_filter, #liquid_tag
#connection, #get
#inspect_html, #inspect_xml, process_html, process_xml, setup_nokogiri, setup_nokolexbor
#add_data, #hook
#helper, #helpers
#generator
#<=>, included
Class Method Details
.add_callback(name, method_name = nil, &block) ⇒ Object
23
24
25
26
|
# File 'bridgetown-builder/lib/bridgetown-builder/builder.rb', line 23
def add_callback(name, method_name = nil, &block)
callbacks[name] ||= []
callbacks[name] << (block || proc { send(method_name) })
end
|
.after_build ⇒ Object
15
16
17
|
# File 'bridgetown-builder/lib/bridgetown-builder/builder.rb', line 15
def after_build(...)
add_callback(:after, ...)
end
|
.before_build ⇒ Object
11
12
13
|
# File 'bridgetown-builder/lib/bridgetown-builder/builder.rb', line 11
def before_build(...)
add_callback(:before, ...)
end
|
.callbacks ⇒ Object
19
20
21
|
# File 'bridgetown-builder/lib/bridgetown-builder/builder.rb', line 19
def callbacks
@callbacks ||= {}
end
|
.descendants ⇒ Object
40
41
42
43
|
# File 'bridgetown-builder/lib/bridgetown-builder/builder.rb', line 40
def self.descendants
site_builder_name = "SiteBuilder"
super.reject { |klass| [site_builder_name].include?(klass.name) }
end
|
Instance Method Details
#build_with_callbacks ⇒ Object
29
30
31
32
33
34
|
# File 'bridgetown-builder/lib/bridgetown-builder/builder.rb', line 29
def build_with_callbacks
self.class.callbacks[:before]&.each { instance_exec(&_1) }
build
self.class.callbacks[:after]&.each { instance_exec(&_1) }
self
end
|
#inspect ⇒ Object
36
37
38
|
# File 'bridgetown-builder/lib/bridgetown-builder/builder.rb', line 36
def inspect
"#<#{name}>"
end
|