Module: UniOne::Validation::ClassMethods

Instance Method Summary collapse

Instance Method Details

#add_response_validations(klass, methods) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/unione/validation.rb', line 7

def add_response_validations(klass, methods)
  methods.each do |method|
    orig = "#{method}_without_hook"
    alias_method orig, method

    define_method method do |*args|
      send(orig, *args)
      schema = get_response_schema(klass, method)
      validate_response(schema)
    end
  end
end