Class: Adaptors::Adaptor
- Inherits:
-
Object
show all
- Includes:
- Validates
- Defined in:
- lib/bureaucrat/validation_old.rb
Instance Method Summary
collapse
Constructor Details
#initialize(allow_blank = false) ⇒ Adaptor
Returns a new instance of Adaptor.
21
22
23
|
# File 'lib/bureaucrat/validation_old.rb', line 21
def initialize(allow_blank=false)
@allow_blank = allow_blank
end
|
Instance Method Details
#adapt(value) ⇒ Object
34
35
36
|
# File 'lib/bureaucrat/validation_old.rb', line 34
def adapt(value)
value
end
|
#to_object(value) ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/bureaucrat/validation_old.rb', line 25
def to_object(value)
if blank?(value)
fail_with(:blank) unless @allow_blank
nil
else
adapt(value)
end
end
|