Class: Relaxo::Model::Properties::Serialized

Inherits:
Object
  • Object
show all
Defined in:
lib/relaxo/model/properties/attribute.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, &serialization) ⇒ Serialized

Returns a new instance of Serialized.

Raises:

  • (ArgumentError)


54
55
56
57
58
# File 'lib/relaxo/model/properties/attribute.rb', line 54

def initialize(klass, &serialization)
	@klass = klass
	
	raise ArgumentError.new("Klass doesn't respond to parse!") unless @klass.respond_to? :parse
end

Class Method Details

.[](klass, proc = nil) ⇒ Object



50
51
52
# File 'lib/relaxo/model/properties/attribute.rb', line 50

def self.[] (klass, proc = nil)
	self.new(klass, &proc)
end

Instance Method Details

#convert_from_primative(database, value) ⇒ Object



64
65
66
# File 'lib/relaxo/model/properties/attribute.rb', line 64

def convert_from_primative(database, value)
	@klass.parse(value)
end

#convert_to_primative(value) ⇒ Object



60
61
62
# File 'lib/relaxo/model/properties/attribute.rb', line 60

def convert_to_primative(value)
	value.to_s
end