Sha256: b943203b009cedb495a9b016a312fbca3f8ce3d328fb0b5e46a17963293203a4

Contents?: true

Size: 664 Bytes

Versions: 1

Compression:

Stored size: 664 Bytes

Contents

# frozen_string_literal: true

module RSpec
  module Terraform
    module Configuration
      class VarCaptor
        def initialize(vars)
          @vars = vars
        end

        def method_missing(method, *args, &)
          if method.to_s =~ /.*=$/
            set_var(method.to_s.chop.to_sym, args[0])
          else
            read_var(method)
          end
        end

        def respond_to_missing?
          true
        end

        def to_h
          @vars
        end

        private

        def set_var(var, value)
          @vars[var] = value
        end

        def read_var(var)
          @vars[var]
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-terraform-0.5.0.pre.9 lib/rspec/terraform/configuration/var_captor.rb