class FlexValidations::Decorate

Not a really validation but handy class for complex validations

@example

hash = FlexValidations::Chain.new(
  FlexValidations::Call.new(:keys),
  FlexValidations::Decorate.new(Set),
  FlexValidations::Predicate.new(:==, Set.new(["id", "title"]))
)

Public Class Methods

new(decorator_class, *decorator_args) click to toggle source
# File lib/flex_validations/decorate.rb, line 15
def initialize(decorator_class, *decorator_args)
  @decorator_class = decorator_class
  @decorator_args = decorator_args
end

Public Instance Methods

to_s() click to toggle source

@return [String]

# File lib/flex_validations/decorate.rb, line 30
def to_s
  "decorate value with #{@decorator_class}"
end
validate(value) click to toggle source

@param value [Object] Value to be validated

@return [FlexValidations::Result]

# File lib/flex_validations/decorate.rb, line 23
def validate(value)
  new_val = @decorator_class.new value, *@decorator_args

  Result::Success::Simple.new(self, SuccessMessage.new(value, new_val), value, new_val)
end