Class: DataMapper::Property::IPAddress
- Inherits:
-
String
- Object
- String
- DataMapper::Property::IPAddress
- Defined in:
- lib/dm-types/ip_address.rb
Instance Method Summary collapse
Instance Method Details
#dump(value) ⇒ Object
25 26 27 |
# File 'lib/dm-types/ip_address.rb', line 25 def dump(value) value.to_s unless value.nil? end |
#load(value) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dm-types/ip_address.rb', line 11 def load(value) if value.nil? || value_loaded?(value) value elsif value.is_a?(::String) if value.empty? IPAddr.new("0.0.0.0") else IPAddr.new(value) end else raise ArgumentError.new("+value+ must be nil or a String") end end |
#typecast(value) ⇒ Object
29 30 31 |
# File 'lib/dm-types/ip_address.rb', line 29 def typecast(value) load(value) unless value.nil? end |