Class: Biosphere::ResourceProxy
- Inherits:
-
Object
- Object
- Biosphere::ResourceProxy
- Defined in:
- lib/biosphere/terraformproxy.rb
Instance Attribute Summary collapse
-
#caller ⇒ Object
readonly
Returns the value of attribute caller.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#initialize(caller) ⇒ ResourceProxy
constructor
A new instance of ResourceProxy.
- #method_missing(symbol, *args) ⇒ Object
- #respond_to?(symbol, include_private = false) ⇒ Boolean
- #set(symbol, value) ⇒ Object
Constructor Details
#initialize(caller) ⇒ ResourceProxy
Returns a new instance of ResourceProxy.
48 49 50 51 |
# File 'lib/biosphere/terraformproxy.rb', line 48 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
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/biosphere/terraformproxy.rb', line 64 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
#caller ⇒ Object (readonly)
Returns the value of attribute caller.
46 47 48 |
# File 'lib/biosphere/terraformproxy.rb', line 46 def caller @caller end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
45 46 47 |
# File 'lib/biosphere/terraformproxy.rb', line 45 def output @output end |
Instance Method Details
#respond_to?(symbol, include_private = false) ⇒ Boolean
56 57 58 |
# File 'lib/biosphere/terraformproxy.rb', line 56 def respond_to?(symbol, include_private = false) return true end |
#set(symbol, value) ⇒ Object
60 61 62 |
# File 'lib/biosphere/terraformproxy.rb', line 60 def set(symbol, value) @output[symbol] = value end |