module SimpleForm::Components::Labels

def self.included(base)

def self.included(base)
  base.extend ClassMethods
end

def label

def label
  @builder.label(label_target, label_text, label_html_options)
end

def label_html_options

def label_html_options
  label_options = html_options_for(:label, input_type, required_class)
  label_options[:for] = options[:input_html][:id] if options.key?(:input_html)
  label_options
end

def label_target

def label_target
  attribute_name
end

def label_text

def label_text
  SimpleForm.label_text.call(raw_label_text, required_label_text)
end

def label_translation #:nodoc:

:nodoc:
TODO Remove me in Rails > 2.3.5
First check human attribute name and then labels.
def label_translation #:nodoc:
  default = if object.class.respond_to?(:human_attribute_name)
    object.class.human_attribute_name(reflection_or_attribute_name.to_s)
  else
    attribute_name.to_s.humanize
  end
  translate(:labels, default)
end

def raw_label_text #:nodoc:

:nodoc:
def raw_label_text #:nodoc:
  options[:label] || label_translation
end

def required_label_text #:nodoc:

:nodoc:
Default required text when attribute is required.
def required_label_text #:nodoc:
  attribute_required? ? self.class.translate_required_html.dup : ''
end