module AxleAttributes module Validations extend ActiveSupport::Concern included do validate :validate_formats end private def validate_formats each_provided_definition do |definition| value = send(definition.name) if value.present? && error = definition.validate(value) errors.add(definition.name, error) end end end def each_provided_definition provided_set.each do |attr| if definition = self.class.attributes[attr] yield definition end end end end end