Sha256: 37dd864bb7e431de29841acc71ed147c93d250da0f638082181bec8bc99ff7c2

Contents?: true

Size: 874 Bytes

Versions: 9

Compression:

Stored size: 874 Bytes

Contents

module Terraspace::Compiler
  class Expander
    extend Memoist
    delegate :expand, :expansion, to: :expander

    def initialize(mod, name)
      @mod, @name = mod, name
    end

    def expander
      expander_class.new(@mod)
    end
    memoize :expander

    def expander_class
      # IE: TerraspacePluginAws::Interfaces::Expander
      klass_name = Terraspace::Plugin.klass("Expander", backend: @name)
      klass_name ? klass_name.constantize : Terraspace::Plugin::Expander::Generic
    rescue NameError
      Terraspace::Plugin::Expander::Generic
    end

    class << self
      extend Memoist

      def autodetect(mod, opts={})
        backend = opts[:backend] || find_backend(mod)
        new(mod, backend)
      end
      memoize :autodetect

      def find_backend(mod)
        Backend.new(mod).detect
      end
      memoize :find_backend
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
terraspace-1.0.5 lib/terraspace/compiler/expander.rb
terraspace-1.0.4 lib/terraspace/compiler/expander.rb
terraspace-1.0.3 lib/terraspace/compiler/expander.rb
terraspace-1.0.2 lib/terraspace/compiler/expander.rb
terraspace-1.0.1 lib/terraspace/compiler/expander.rb
terraspace-1.0.0 lib/terraspace/compiler/expander.rb
terraspace-0.7.2 lib/terraspace/compiler/expander.rb
terraspace-0.7.1 lib/terraspace/compiler/expander.rb
terraspace-0.7.0 lib/terraspace/compiler/expander.rb