Small refactor and review some private methods

This commit is contained in:
Carlos Antonio da Silva 2010-09-26 23:21:30 -03:00
parent 501cf5eab6
commit 66555b1e60
6 changed files with 11 additions and 12 deletions

View File

@ -143,9 +143,7 @@ module SimpleForm
end
end
options[:collection] ||= @reflection.klass.all(
:conditions => @reflection.options[:conditions], :order => @reflection.options[:order]
)
options[:collection] ||= @reflection.klass.all(@reflection.options.slice(:conditions, :order))
input(attribute, options).tap { @reflection = nil }
end

View File

@ -55,4 +55,4 @@ module SimpleForm
end
end
end
end
end

View File

@ -5,6 +5,8 @@ module SimpleForm
@builder.send(:"#{input_type}_select", attribute_name, input_options, input_html_options)
end
private
def label_target
case input_type
when :date, :datetime
@ -15,4 +17,4 @@ module SimpleForm
end
end
end
end
end

View File

@ -1,6 +1,5 @@
module SimpleForm
module Inputs
# Handles hidden input.
class HiddenInput < Base
def render
@builder.hidden_field(attribute_name, input_html_options)
@ -8,4 +7,4 @@ module SimpleForm
alias :input :render
end
end
end
end

View File

@ -12,7 +12,7 @@ module SimpleForm
@builder.send(input_method, attribute_name, input_html_options)
end
private
private
def input_method
self.class.mappings[input_type] or

View File

@ -5,9 +5,9 @@ module SimpleForm
end
def map_type(*types)
options = types.extract_options!
raise ArgumentError, "You need to give :to as option to map_type" unless options[:to]
types.each { |t| mappings[t] = options[:to] }
map_to = types.extract_options![:to]
raise ArgumentError, "You need to give :to as option to map_type" unless map_to
types.each { |t| mappings[t] = map_to }
end
end
end
end