Class: DataMapper::Types::IPAddress

Public Visibility

Public Class Method Summary

dump(value, property)
load(value, property)

Public Class Methods Inherited from DataMapper::Type

bind, configure, inherited, options, primitive

Public Instance Methods Inherited from Object

validatable?

Public Class Method Details

dump

public dump(value, property)
[View source]


20
21
22
23
# File 'dm-more/dm-types/lib/dm-types/ip_address.rb', line 20

def self.dump(value, property)
  return nil if value.nil?
  value.to_s
end

load

public load(value, property)
[View source]


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'dm-more/dm-types/lib/dm-types/ip_address.rb', line 8

def self.load(value, property)
  if value.nil?




    nil
  elsif value.is_a?(String) && !value.empty?
    IPAddr.new(value)
  elsif value.is_a?(String) && value.empty?
    IPAddr.new("0.0.0.0")
  else
    raise ArgumentError.new("+value+ must be nil or a String")
  end
end