Class: DataMapper::Property::PhoneNumber

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

Instance Method Summary collapse

Instance Method Details

#dump(value) ⇒ Object



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

def dump(value)
  case value
    when ::DataMapper::Address::PhoneNumber 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/phone_number.rb', line 8

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

#primitive?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

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