Class: AuthorizedNetworks::Config
- Inherits:
-
Object
- Object
- AuthorizedNetworks::Config
- Defined in:
- lib/authorized_networks/config.rb
Instance Attribute Summary collapse
-
#network_list_cache_ttl ⇒ Integer
The length of time networks should be cached in the instance before being loaded again.
-
#networks ⇒ Hash<Symbol, Array>
Set a networks hash directly in the configuration rather than using a config file file.
-
#networks_file_path ⇒ String
The path where the networks file can be found.
Instance Method Summary collapse
-
#default_groups ⇒ Array<Symbol>
Return an array of groups that are allowed by default when using the ‘AuthorizedNetworks.valid?`.
-
#disable! ⇒ Object
Disable everything.
-
#disabled? ⇒ Boolean
Is this disabled?.
Instance Attribute Details
#network_list_cache_ttl ⇒ Integer
The length of time networks should be cached in the instance before being loaded again. This is in seconds.
34 35 36 |
# File 'lib/authorized_networks/config.rb', line 34 def network_list_cache_ttl @network_list_cache_ttl || 3600 end |
#networks ⇒ Hash<Symbol, Array>
Set a networks hash directly in the configuration rather than using a config file file
28 29 30 |
# File 'lib/authorized_networks/config.rb', line 28 def networks @networks end |
#networks_file_path ⇒ String
The path where the networks file can be found.
7 8 9 |
# 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 |
Instance Method Details
#default_groups ⇒ Array<Symbol>
Return an array of groups that are allowed by default when using the ‘AuthorizedNetworks.valid?`
15 16 17 18 19 20 21 22 23 |
# 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! ⇒ Object
Disable everything. Any call to valid_ip? will be returned as true and no network lists will be loaded.
48 49 50 |
# File 'lib/authorized_networks/config.rb', line 48 def disable! @disabled = true end |
#disabled? ⇒ Boolean
Is this disabled?
42 43 44 |
# File 'lib/authorized_networks/config.rb', line 42 def disabled? @disabled || false end |