Class: Bridgetown::Builder

Inherits:
Bridgetown::Builders::PluginBuilder show all
Defined in:
lib/bridgetown-builder/builder.rb

Overview

Superclass for a website’s SiteBuilder abstract class

Instance Attribute Summary

Attributes inherited from Bridgetown::Builders::PluginBuilder

#config, #functions, #name, #site

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Bridgetown::Builders::PluginBuilder

#doc

Methods included from Bridgetown::Builders::DSL::Liquid

#liquid_filter, #liquid_tag

Methods included from Bridgetown::Builders::DSL::HTTP

#connection, #get

Methods included from Bridgetown::Builders::DSL::Hooks

#add_data, #hook

Methods included from Bridgetown::Builders::DSL::Helpers

#helper

Methods included from Bridgetown::Builders::DSL::Generators

#generator

Constructor Details

#initialize(name, current_site = nil) ⇒ Builder

Subclass is expected to implement #build



15
16
17
18
# File 'lib/bridgetown-builder/builder.rb', line 15

def initialize(name, current_site = nil)
  super(name, current_site)
  build
end

Class Method Details

.catch_inheritance(const) ⇒ Object



31
32
33
34
35
36
# File 'lib/bridgetown-builder/builder.rb', line 31

def self.catch_inheritance(const)
  const.define_singleton_method :inherited do |const_|
    (@children ||= Set.new).add const_
    yield const_ if block_given?
  end
end

.descendantsObject



38
39
40
41
42
43
# File 'lib/bridgetown-builder/builder.rb', line 38

def self.descendants
  @children ||= Set.new
  out = @children.map(&:descendants)
  out << self unless ["SiteBuilder", "Bridgetown::Builder"].include?(name)
  Set.new(out).flatten
end

.inherited(const) ⇒ Object



24
25
26
27
28
29
# File 'lib/bridgetown-builder/builder.rb', line 24

def self.inherited(const)
  (@children ||= Set.new).add const
  catch_inheritance(const) do |const_|
    catch_inheritance(const_)
  end
end

.registerObject



7
8
9
10
11
# File 'lib/bridgetown-builder/builder.rb', line 7

def register
  Bridgetown::Hooks.register_one :site, :pre_read, reloadable: false do |site|
    new(name, site)
  end
end

Instance Method Details

#inspectObject



20
21
22
# File 'lib/bridgetown-builder/builder.rb', line 20

def inspect
  name
end