Class: WebConsole::Permissions
- Inherits:
-
Object
- Object
- WebConsole::Permissions
- Defined in:
- lib/web_console/permissions.rb
Constant Summary collapse
- ALWAYS_PERMITTED_NETWORKS =
IPv4 and IPv6 localhost should be always allowed.
%w( 127.0.0.0/8 ::1 )
Instance Method Summary collapse
- #include?(network) ⇒ Boolean
-
#initialize(networks = nil) ⇒ Permissions
constructor
A new instance of Permissions.
- #to_s ⇒ Object
Constructor Details
#initialize(networks = nil) ⇒ Permissions
Returns a new instance of Permissions.
10 11 12 |
# File 'lib/web_console/permissions.rb', line 10 def initialize(networks = nil) @networks = normalize_networks(networks).map(&method(:coerce_network_to_ipaddr)).uniq end |
Instance Method Details
#include?(network) ⇒ Boolean
14 15 16 17 18 |
# File 'lib/web_console/permissions.rb', line 14 def include?(network) @networks.any? { || .include?(network.to_s) } rescue IPAddr::InvalidAddressError false end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/web_console/permissions.rb', line 20 def to_s @networks.map(&method(:human_readable_ipaddr)).join(", ") end |