Class: DataMapper::Property::ZipCode

Inherits:
String
  • Object
show all
Defined in:
lib/dm-types/zip_code.rb

Instance Method Summary collapse

Instance Method Details

#dump(value) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/dm-types/zip_code.rb', line 17

def dump(value)
  case value
    when ::DataMapper::Address::ZipCode then value.to_str
    when ::String then value
    else
      nil
  end
end

#load(value) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/dm-types/zip_code.rb', line 8

def load(value)
  case value
    when ::DataMapper::Address::ZipCode then value
    when ::String then DataMapper::Address::ZipCode.new(value)
    else
      nil
  end
end

#primitive?(value) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/dm-types/zip_code.rb', line 4

def primitive?(value)
  super || value.kind_of?(::DataMapper::Address::ZipCode)
end