Class: Valid
- Inherits:
-
MethodDecorators::Decorator
- Object
- MethodDecorators::Decorator
- Valid
- Defined in:
- lib/decoractors/valid.rb
Instance Method Summary collapse
- #call(wrapped, this, *args, &blk) ⇒ Object
-
#initialize(validate_function, arguments) ⇒ Valid
constructor
A new instance of Valid.
- #validate(arguments, *args, &blk) ⇒ Object
Constructor Details
#initialize(validate_function, arguments) ⇒ Valid
Returns a new instance of Valid.
4 5 6 7 |
# File 'lib/decoractors/valid.rb', line 4 def initialize(validate_function, arguments) @validate_function = validate_function @arguments = arguments end |
Instance Method Details
#call(wrapped, this, *args, &blk) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/decoractors/valid.rb', line 9 def call(wrapped, this, *args, &blk) puts "before validation" if self.send(@validate_function, @arguments, *args, &blk) result = wrapped.call(*args, &blk) else raise CommonError::InvalidData end puts "after validation" result end |
#validate(arguments, *args, &blk) ⇒ Object
20 21 22 23 |
# File 'lib/decoractors/valid.rb', line 20 def validate(arguments, *args, &blk) # check validation here return true end |