Class: Relaxo::Model::Properties::Optional
- Inherits:
-
Object
- Object
- Relaxo::Model::Properties::Optional
- Defined in:
- lib/relaxo/model/properties/attribute.rb
Class Method Summary collapse
Instance Method Summary collapse
- #blank?(value) ⇒ Boolean
- #convert_from_primative(dataset, value) ⇒ Object
- #convert_to_primative(value) ⇒ Object
-
#initialize(klass) ⇒ Optional
constructor
A new instance of Optional.
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
#blank?(value) ⇒ Boolean
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/relaxo/model/properties/attribute.rb', line 78 def blank?(value) if value.nil? return true end if value.respond_to?(:empty?) && value.empty? return true end return false end |
#convert_from_primative(dataset, value) ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/relaxo/model/properties/attribute.rb', line 98 def convert_from_primative(dataset, value) if blank?(value) nil else @klass.convert_from_primative(dataset, value) end end |
#convert_to_primative(value) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/relaxo/model/properties/attribute.rb', line 90 def convert_to_primative(value) if blank?(value) nil else @klass.convert_to_primative(value) end end |