Class: String

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

Instance Method Summary collapse

Instance Method Details

#cfnizeObject



60
61
62
63
# File 'lib/monkeypatch.rb', line 60

def cfnize
  return self if self !~ /_/ && self =~ /[A-Z]+.*/
  split("_").map(&:capitalize).join
end

#fngetazsObject



106
107
108
109
110
# File 'lib/monkeypatch.rb', line 106

def fngetazs
  {
    "Fn::GetAZs": self
  }
end

#fnimportvalueObject Also known as: fnimport



124
125
126
127
128
# File 'lib/monkeypatch.rb', line 124

def fnimportvalue
  {
    "Fn::Import": self
  }
end

#fnsplit(separator = "") ⇒ Object



97
98
99
100
101
102
103
104
# File 'lib/monkeypatch.rb', line 97

def fnsplit(separator = "")
  {
    "Fn::Split": [
      separator,
      self
    ]
  }
end

#fnsub(variable_map = nil) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
# File 'lib/monkeypatch.rb', line 112

def fnsub(variable_map = nil)
  unless variable_map
    return { "Fn::Sub": self }
  end
  {
    "Fn::Sub": [
      self,
      variable_map
    ]
  }
end

#fntransform(parameters = nil) ⇒ Object



87
88
89
90
91
92
93
94
95
# File 'lib/monkeypatch.rb', line 87

def fntransform(parameters = nil)
  raise "fntransform parameters must be of type Hash" unless parameters.class == Hash
  {
    "Fn::Transform": {
      "Name": self,
      "Parameters": parameters
    }
  }
end

#get_output(attr) ⇒ Object



65
66
67
68
69
70
71
72
# File 'lib/monkeypatch.rb', line 65

def get_output(attr)
  attr = attr.class == String ? attr : attr.to_s.split("_").map(&:capitalize).join
  {
    "Fn::GetAtt": [
      to_s.split("_").map(&:capitalize).join, "Outputs.#{attr}"
    ]
  }
end

#ref(attr = nil) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/monkeypatch.rb', line 74

def ref(attr = nil)
  unless attr
    return { Ref: self }
  end
  attr = attr.class == String ? attr : attr.to_s.split("_").map(&:capitalize).join
  {
    "Fn::GetAtt": [
      self,
      attr
    ]
  }
end