Move HasErrors to helpers.

This commit is contained in:
José Valim 2011-09-03 12:04:23 +02:00
parent a4655ba845
commit 3387cc7066
6 changed files with 18 additions and 17 deletions

View File

@ -6,7 +6,6 @@ module SimpleForm
autoload :Components, 'simple_form/components'
autoload :ErrorNotification, 'simple_form/error_notification'
autoload :FormBuilder, 'simple_form/form_builder'
autoload :HasErrors, 'simple_form/has_errors'
autoload :Helpers, 'simple_form/helpers'
autoload :I18nCache, 'simple_form/i18n_cache'
autoload :Inputs, 'simple_form/inputs'

View File

@ -1,7 +1,7 @@
module SimpleForm
module Components
module Errors
include SimpleForm::HasErrors
include SimpleForm::Helpers::HasErrors
def error
template.content_tag(error_tag, error_text, error_html_options) if has_errors?

View File

@ -1,7 +1,7 @@
module SimpleForm
class ErrorNotification
delegate :object, :object_name, :template, :to => :@builder
include SimpleForm::HasErrors
include SimpleForm::Helpers::HasErrors
def initialize(builder, options)
@builder = builder

View File

@ -1,14 +0,0 @@
module SimpleForm
module HasErrors
protected
def errors
object.errors
end
def has_errors?
object && object.respond_to?(:errors) && errors.present?
end
end
end

View File

@ -1,5 +1,6 @@
module SimpleForm
module Helpers
autoload :HasErrors, 'simple_form/helpers/has_errors'
autoload :Maxlength, 'simple_form/helpers/maxlength'
autoload :Pattern, 'simple_form/helpers/pattern'
autoload :Validators, 'simple_form/helpers/validators'

View File

@ -0,0 +1,15 @@
module SimpleForm
module Helpers
module HasErrors
private
def errors
object.errors
end
def has_errors?
object && object.respond_to?(:errors) && errors.present?
end
end
end
end