Class: Relaxo::Model::Properties::Optional

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) ⇒ Optional

Returns a new instance of Optional.



74
75
76
# File 'lib/relaxo/model/properties/attribute.rb', line 74

def initialize(klass)
	@klass = klass
end

Class Method Details

.[](klass) ⇒ Object



70
71
72
# File 'lib/relaxo/model/properties/attribute.rb', line 70

def self.[] klass
	self.new(klass)
end

Instance Method Details

#convert_from_primative(dataset, value) ⇒ Object



86
87
88
89
90
91
92
# File 'lib/relaxo/model/properties/attribute.rb', line 86

def convert_from_primative(dataset, value)
	if value.nil? or value.empty?
		nil
	else
		@klass.convert_from_primative(dataset, value)
	end
end

#convert_to_primative(value) ⇒ Object



78
79
80
81
82
83
84
# File 'lib/relaxo/model/properties/attribute.rb', line 78

def convert_to_primative(value)
	if value.nil? or (value.respond_to?(:empty?) and value.empty?)
		nil
	else
		@klass.convert_to_primative(value)
	end
end