Class: AuthorizedNetworks::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/authorized_networks/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#network_list_cache_ttlInteger

The length of time networks should be cached in the instance before being loaded again. This is in seconds.

Returns:

  • (Integer)


34
35
36
# File 'lib/authorized_networks/config.rb', line 34

def network_list_cache_ttl
  @network_list_cache_ttl || 3600
end

#networksHash<Symbol, Array>

Set a networks hash directly in the configuration rather than using a config file file

Returns:

  • (Hash<Symbol, Array>)


28
29
30
# File 'lib/authorized_networks/config.rb', line 28

def networks
  @networks
end

#networks_file_pathString

The path where the networks file can be found.

Returns:

  • (String)


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_groupsArray<Symbol>

Return an array of groups that are allowed by default when using the ‘AuthorizedNetworks.valid?`

Returns:

  • (Array<Symbol>)


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?

Returns:

  • (Boolean)


42
43
44
# File 'lib/authorized_networks/config.rb', line 42

def disabled?
  @disabled || false
end