class Field::Form

Attributes

form_class[RW]

Public Instance Methods

attribute() click to toggle source
# File lib/field/form.rb, line 26
def attribute
  @form_class
end
inject_attributes() click to toggle source
# File lib/field/form.rb, line 9
def inject_attributes
  @container.attribute @name, attribute, default: attribute.new
end
inject_validations() click to toggle source
# File lib/field/form.rb, line 13
def inject_validations
  @container.class_eval %Q{
    method = "__ensure_valid_#{name.to_s}__"
    validate method

    define_method method do
      unless send('#{name}').send(:valid?)
        errors.add(:base, "Invalid #{name.to_s}")
      end
    end
  }
end