Class: Pancake::BootLoaderMixin::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/pancake/bootloaders.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base

Returns a new instance of Base.



34
35
36
# File 'lib/pancake/bootloaders.rb', line 34

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject

:api: :public



7
8
9
# File 'lib/pancake/bootloaders.rb', line 7

def config
  @config
end

Class Method Details

.call(config) ⇒ Object

Creates a new instance and runs it :api: private



40
41
42
# File 'lib/pancake/bootloaders.rb', line 40

def self.call(config)
  new(config).run!
end

.optionsObject

Provides access to the bootloader options :api: private



20
21
22
# File 'lib/pancake/bootloaders.rb', line 20

def self.options # :nodoc:
  @options ||= {}
end

.options=(opts = {}) ⇒ Object

Sets options for the bootloder By including conditions in the bootloader when you declare it You can selectively run bootloaders later :api: private



13
14
15
16
# File 'lib/pancake/bootloaders.rb', line 13

def self.options=(opts={}) # :nodoc:
  @options = opts
  @options[:level] ||= :default
end

.run?(conditions = {}) ⇒ Boolean

Checks the conditions with the options of the bootloader To see if this one should be run Only the central bootloaders with the conditions will be checked :api: private

Returns:

  • (Boolean)


48
49
50
51
52
53
54
55
56
57
# File 'lib/pancake/bootloaders.rb', line 48

def self.run?(conditions = {})
  opts = options
  if conditions.keys.include?(:only)
    return conditions[:only].all?{|k,v| opts[k] == v}
  end
  if conditions.keys.include?(:except)
    return conditions[:except].all?{|k,v| opts[k] != v}
  end
  true
end

Instance Method Details

#stackObject



24
25
26
27
# File 'lib/pancake/bootloaders.rb', line 24

def stack
  raise "No Stack Configured" unless @config[:stack]
  @config[:stack]
end

#stack_classObject



29
30
31
32
# File 'lib/pancake/bootloaders.rb', line 29

def stack_class
  raise "No Stack Class Configured" unless @config[:stack_class]
  @config[:stack_class]
end