Module: DIDWW::Types::IpAddresses

Defined in:
lib/didww/types/ip_addresses.rb

Class Method Summary collapse

Class Method Details

.cast(values, default) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/didww/types/ip_addresses.rb', line 8

def cast(values, default)
  return default unless values.is_a?(Array)

  values.map do |value|
    cast_item(value)
  end
rescue IPAddr::Error
  default
end

.cast_item(value) ⇒ Object



18
19
20
# File 'lib/didww/types/ip_addresses.rb', line 18

def cast_item(value)
  value.is_a?(IPAddr) ? value : IPAddr.new(value)
end