Class: DataMapper::Types::Regexp

Inherits:
DataMapper::Type
  • Object
show all
Defined in:
lib/dm-types/regexp.rb

Class Method Summary collapse

Class Method Details

.dump(value, property) ⇒ Object



10
11
12
13
# File 'lib/dm-types/regexp.rb', line 10

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

.load(value, property) ⇒ Object



6
7
8
# File 'lib/dm-types/regexp.rb', line 6

def self.load(value, property)
  ::Regexp.new(value) unless value.nil?
end

.typecast(value, property) ⇒ Object



15
16
17
# File 'lib/dm-types/regexp.rb', line 15

def self.typecast(value, property)
  value.kind_of?(::Regexp) ? value : load(value, property)
end