Sha256: 1b77de487f2617f41fdef0d8b3baed4513ce1f39c67fa642ba50b0094385ca00

Contents?: true

Size: 776 Bytes

Versions: 3

Compression:

Stored size: 776 Bytes

Contents

require 'minarai/recipe'
require 'minarai/loaders/base'
require 'minarai/loaders/variable_loader'
require 'minarai/variable'

module Minarai
  module Loaders
    class RecipeLoader < Base
      def initialize(path, variable_path: nil)
        super(path)
        @variable_path = variable_path
      end

      private

      def loaded_class
        Minarai::Recipe
      end

      def has_variable_path?
        !@variable_path.nil?
      end

      def binding_for_erb
        variables.to_mash.binding
      end

      def variables
        @variables ||= begin
          if has_variable_path?
            Minarai::Loaders::VariableLoader.new(@variable_path).load
          else
            Minarai::Variable.new({})
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
minarai-0.0.3 lib/minarai/loaders/recipe_loader.rb
minarai-0.0.2 lib/minarai/loaders/recipe_loader.rb
minarai-0.0.1 lib/minarai/loaders/recipe_loader.rb