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.



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

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.



32
33
34
# File 'lib/holepunch/definition.rb', line 32

def dependency
  @dependency
end

#descObject

Returns the value of attribute desc.



32
33
34
# File 'lib/holepunch/definition.rb', line 32

def desc
  @desc
end

#idObject

Returns the value of attribute id.



32
33
34
# File 'lib/holepunch/definition.rb', line 32

def id
  @id
end

#ingressesObject

Returns the value of attribute ingresses.



32
33
34
# File 'lib/holepunch/definition.rb', line 32

def ingresses
  @ingresses
end

Instance Method Details

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

Returns:

  • (Boolean)


45
46
47
48
49
50
51
# File 'lib/holepunch/definition.rb', line 45

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