Class: DataMapper::Property::AppEngineStringType

Inherits:
String
  • Object
show all
Defined in:
lib/dm-appengine/properties/string.rb

Direct Known Subclasses

Blob, ByteString, Category, Email, Link, PhoneNumber, PostalAddress

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, name, options = {}, type = nil) ⇒ AppEngineStringType

Overriding the default string length.



21
22
23
24
# File 'lib/dm-appengine/properties/string.rb', line 21

def initialize(model, name, options = {}, type = nil)
  super
  @length = @options.fetch(:length, self.class.length)
end

Class Method Details

.dump(value, property) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/dm-appengine/properties/string.rb', line 4

def self.dump(value, property)
  if value.nil?
    nil
  else
    typecast(value)
  end
end

.inherited(klass) ⇒ Object



26
27
28
# File 'lib/dm-appengine/properties/string.rb', line 26

def self.inherited klass
  klass.extend ClassMethods
end

.load(value, property) ⇒ Object



12
13
14
# File 'lib/dm-appengine/properties/string.rb', line 12

def self.load(value, property)
  value
end

Instance Method Details

#typecast_to_primitive(value) ⇒ Object



16
17
18
# File 'lib/dm-appengine/properties/string.rb', line 16

def typecast_to_primitive(value)
  primitive.new(value) if value
end