Class: Biosphere::ResourceProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/biosphere/terraformproxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(caller) ⇒ ResourceProxy



40
41
42
43
# File 'lib/biosphere/terraformproxy.rb', line 40

def initialize(caller)
    @output = {}
    @caller = caller
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/biosphere/terraformproxy.rb', line 50

def method_missing(symbol, *args)
    #puts ">>>>>>>> method missing: #{symbol}, #{args}"

    if @caller.methods.include?(symbol)
        return @caller.method(symbol).call(*args)
    end

    # Support getter here
    if args.length == 0
        return @output[symbol]
    end

    # Support setter here
    if [:ingress, :egress, :route].include?(symbol)
        @output[symbol] ||= []
        if args[0].kind_of?(Array)
            @output[symbol] += args[0]
        else
            @output[symbol] << args[0]
        end
    else
        @output[symbol] = args[0]
    end

    # We need to first gzip and then base64-encode the user_data string to work around the 16kb size limitation in AWS
    if symbol === :user_data
      @output[symbol] = Base64.strict_encode64(Zlib::Deflate.new(nil, 31).deflate(args[0], Zlib::FINISH))
    end
end

Instance Attribute Details

#callerObject (readonly)

Returns the value of attribute caller.



38
39
40
# File 'lib/biosphere/terraformproxy.rb', line 38

def caller
  @caller
end

#outputObject (readonly)

Returns the value of attribute output.



37
38
39
# File 'lib/biosphere/terraformproxy.rb', line 37

def output
  @output
end

Instance Method Details

#respond_to?(symbol, include_private = false) ⇒ Boolean



46
47
48
# File 'lib/biosphere/terraformproxy.rb', line 46

def respond_to?(symbol, include_private = false)
    return true
end