Class: IpRestriction::IpLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/ip_restriction/ip_loader.rb

Constant Summary collapse

DEFAULT_IPS =
['127.0.0.1', '::1']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ IpLoader

Returns a new instance of IpLoader.



9
10
11
# File 'lib/ip_restriction/ip_loader.rb', line 9

def initialize(file_path)
  @file_path = file_path
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



7
8
9
# File 'lib/ip_restriction/ip_loader.rb', line 7

def file_path
  @file_path
end

Instance Method Details

#loadObject



13
14
15
16
17
18
19
# File 'lib/ip_restriction/ip_loader.rb', line 13

def load
  unless File.exist? file_path
    warn "LwIpRestriction: file #{file_path} does not exist"
    return DEFAULT_IPS
  end
  YAML.load_file(file_path)['ips']
end