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)


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

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



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

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

Instance Method Details

#convert_from_primative(database, value) ⇒ Object



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

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

#convert_to_primative(value) ⇒ Object



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

def convert_to_primative(value)
	value.to_s
end