Module: ApplicationForm::ClassMethods

Defined in:
lib/application_form.rb

Instance Method Summary collapse

Instance Method Details

#_permitted_argsObject



34
35
36
# File 'lib/application_form.rb', line 34

def _permitted_args
  @_permitted_args || (superclass.respond_to?(:_permitted_args) && superclass._permitted_args) || []
end

#check(key, block, field = :base) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/application_form.rb', line 38

def check(key, block, field = :base)
  validate do |form|
    if !block.call(form)
      entity_name = self.class.superclass.to_s.tableize.split('/').last.singularize
      full_key = "#{entity_name}.errors.#{key}"
      form.add_error_key(field, full_key)
    end
  end
end

#permit(*args) ⇒ Object



30
31
32
# File 'lib/application_form.rb', line 30

def permit(*args)
  @_permitted_args = args
end