class AuthorizedNetworks::Config
Attributes
network_list_cache_ttl[W]
networks[RW]
Set a networks hash directly in the configuration rather than using a config file file
@return [Hash<Symbol, Array>]
networks_file_path[W]
Public Instance Methods
default_groups()
click to toggle source
Return an array of groups that are allowed by default when using the `AuthorizedNetworks.valid?`
@return [Array<Symbol>]
# File lib/authorized_networks/config.rb, line 15 def default_groups @default_groups ||= begin if ENV['AUTHORIZED_NETWORK_GROUPS'].is_a?(String) group_list_from_env(ENV['AUTHORIZED_NETWORK_GROUPS']) else [:default] end end end
disable!()
click to toggle source
Disable everything. Any call to valid_ip? will be returned as true and no network lists will be loaded.
# File lib/authorized_networks/config.rb, line 48 def disable! @disabled = true end
disabled?()
click to toggle source
Is this disabled?
@return [Boolean]
# File lib/authorized_networks/config.rb, line 42 def disabled? @disabled || false end
network_list_cache_ttl()
click to toggle source
The length of time networks should be cached in the instance before being loaded again. This is in seconds.
@return [Integer]
# File lib/authorized_networks/config.rb, line 34 def network_list_cache_ttl @network_list_cache_ttl || 3600 end
networks_file_path()
click to toggle source
The path where the networks file can be found.
@return [String]
# File lib/authorized_networks/config.rb, line 7 def networks_file_path @networks_file_path || ENV['AUTHORIZED_NETWORKS_CONFIG_PATH'] || find_default_networks_file_path end
Private Instance Methods
find_default_networks_file_path()
click to toggle source
# File lib/authorized_networks/config.rb, line 54 def find_default_networks_file_path if defined?(Rails) Rails.root.join('config', 'authorized_networks.yml') else "/etc/authorized_networks.yml" end end
group_list_from_env(string)
click to toggle source
# File lib/authorized_networks/config.rb, line 62 def group_list_from_env(string) string.split(/\s*\,\s*/).map(&:to_sym) end