Class: HolePunch::SecurityGroup

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, opts = {}) ⇒ SecurityGroup

Returns a new instance of SecurityGroup.



25
26
27
28
29
30
31
32
33
34
# File 'lib/holepunch/definition.rb', line 25

def initialize(id, opts = {})
  opts = {
    dependency: false
  }.merge(opts)

  @id         = id
  @desc       = id
  @dependency = opts[:dependency]
  @ingresses  = []
end

Instance Attribute Details

#dependencyObject

Returns the value of attribute dependency.



23
24
25
# File 'lib/holepunch/definition.rb', line 23

def dependency
  @dependency
end

#descObject

Returns the value of attribute desc.



23
24
25
# File 'lib/holepunch/definition.rb', line 23

def desc
  @desc
end

#idObject

Returns the value of attribute id.



23
24
25
# File 'lib/holepunch/definition.rb', line 23

def id
  @id
end

#ingressesObject

Returns the value of attribute ingresses.



23
24
25
# File 'lib/holepunch/definition.rb', line 23

def ingresses
  @ingresses
end

Instance Method Details

#include_ingress?(type, ports, source) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
40
41
42
# File 'lib/holepunch/definition.rb', line 36

def include_ingress?(type, ports, source)
  ports = ports.first if ports.is_a?(Range) and ports.size == 1

  ingresses.any? do |ingress|
    ingress.type == type && ingress.ports == ports && ingress.sources.include?(source)
  end
end