class Serverkit::Loaders::RecipeLoader

Constants

DEFAULT_VARIABLES_DATA

Public Class Methods

new(path, variables_path: nil) click to toggle source

@param [String] path @param [String, nil] variables_path

Calls superclass method Serverkit::Loaders::BaseLoader::new
# File lib/serverkit/loaders/recipe_loader.rb, line 12
def initialize(path, variables_path: nil)
  super(path)
  @variables_path = variables_path
end

Private Instance Methods

binding_for_erb() click to toggle source

@note Override @return [Binding]

# File lib/serverkit/loaders/recipe_loader.rb, line 21
def binding_for_erb
  variables.to_mash.binding
end
create_empty_loadable() click to toggle source

@note Override to pass @variables_path

# File lib/serverkit/loaders/recipe_loader.rb, line 26
def create_empty_loadable
  loaded_class.new({}, @variables_path)
end
has_variables_path?() click to toggle source
# File lib/serverkit/loaders/recipe_loader.rb, line 30
def has_variables_path?
  !@variables_path.nil?
end
load_from_data() click to toggle source

@note Override to pass @variables_path

# File lib/serverkit/loaders/recipe_loader.rb, line 35
def load_from_data
  loaded_class.new(load_data, @variables_path)
end
load_variables() click to toggle source

@return [Serverkit::Variables]

# File lib/serverkit/loaders/recipe_loader.rb, line 40
def load_variables
  Loaders::VariablesLoader.new(@variables_path).load
end
loaded_class() click to toggle source

@note Implementation

# File lib/serverkit/loaders/recipe_loader.rb, line 45
def loaded_class
  Serverkit::Recipe
end
variables() click to toggle source

@return [Serverkit::Variables]

# File lib/serverkit/loaders/recipe_loader.rb, line 50
def variables
  @variables ||= begin
    if has_variables_path?
      load_variables
    else
      Variables.new(DEFAULT_VARIABLES_DATA.dup)
    end
  end
end