Class: Relaxo::Model::Properties::Attribute

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

Overview

Handle conversions for standard datatypes.

Constant Summary collapse

@@attributes =
{}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, &serialization) ⇒ Attribute

Returns a new instance of Attribute.



38
39
40
41
42
43
44
45
46
# File 'lib/relaxo/model/properties/attribute.rb', line 38

def initialize(klass, &serialization)
	@klass = klass
	
	if block_given?
		self.instance_eval(&serialization)
	else
		self.instance_eval(&@@attributes[klass])
	end
end

Class Method Details

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



34
35
36
# File 'lib/relaxo/model/properties/attribute.rb', line 34

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

.for_class(klass, &block) ⇒ Object



30
31
32
# File 'lib/relaxo/model/properties/attribute.rb', line 30

def self.for_class(klass, &block)
	@@attributes[klass] = Proc.new(&block)
end