Class: WebHookDispatcher::Acl::EntryBase

Inherits:
Object
  • Object
show all
Defined in:
lib/webhook-dispatcher/acl/entry_base.rb,
lib/webhook-dispatcher/acl/entry_base.rb

Direct Known Subclasses

AllowEntry, DenyEntry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ EntryBase

Returns a new instance of EntryBase.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/webhook-dispatcher/acl/entry_base.rb', line 12

def initialize(options = nil)
  case options
  when nil, :all
    @addr = nil
    @name = nil
    @port = nil
  when Hash
    options = options.dup
    @addr = normalize_addr(options.delete(:addr))
    @name = normalize_name(options.delete(:name))
    @port = normalize_port(options.delete(:port))
    raise(ArgumentError) unless options.empty?
  else raise(ArgumentError)
  end
end

Instance Attribute Details

#addrObject (readonly)

Returns the value of attribute addr.



28
29
30
# File 'lib/webhook-dispatcher/acl/entry_base.rb', line 28

def addr
  @addr
end

#nameObject (readonly)

Returns the value of attribute name.



28
29
30
# File 'lib/webhook-dispatcher/acl/entry_base.rb', line 28

def name
  @name
end

#portObject (readonly)

Returns the value of attribute port.



28
29
30
# File 'lib/webhook-dispatcher/acl/entry_base.rb', line 28

def port
  @port
end

Instance Method Details

#==(other) ⇒ Object



30
31
32
33
# File 'lib/webhook-dispatcher/acl/entry_base.rb', line 30

def ==(other)
  return false unless other.instance_of?(self.class)
  return (self.to_a == other.to_a)
end

#match?(addr, name, port) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/webhook-dispatcher/acl/entry_base.rb', line 35

def match?(addr, name, port)
  return match_addr?(addr) && match_name?(name) && match_port?(port)
end

#to_aObject



43
44
45
# File 'lib/webhook-dispatcher/acl/entry_base.rb', line 43

def to_a
  return [@addr, @name, @port]
end

#valueObject

Raises:

  • (NotImplementedError)


39
40
41
# File 'lib/webhook-dispatcher/acl/entry_base.rb', line 39

def value
  raise(NotImplementedError)
end