Module: Fluxo::ActiveModelExtension::ClassMethods

Defined in:
lib/fluxo/active_model_extension.rb

Instance Method Summary collapse

Instance Method Details

#validations(&block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fluxo/active_model_extension.rb', line 6

def validations(&block)
  @validations_proxy ||= build_validations_proxy!
  return unless block_given?

  begin
    @validations_proxy.class_eval(&block)
  rescue => e
    raise ValidationDefinitionError, <<~ERROR
      Invalid validations for #{self.class.name}.

      #{e.message}
    ERROR
  end
end