diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2013-05-04 15:09:22 +0200 |
---|---|---|
committer | Łukasz Strzałkowski <lukasz.strzalkowski@gmail.com> | 2013-06-20 17:23:15 +0200 |
commit | 0d6e8edc2a47a4b4c6824936632bfb83850db343 (patch) | |
tree | 8829bfb94756e48e9489c4e8d22bb41df251bc81 /actionpack/lib/action_view/helpers/tags/collection_helpers.rb | |
parent | 78b0934dd1bb84e8f093fb8ef95ca99b297b51cd (diff) | |
download | rails-0d6e8edc2a47a4b4c6824936632bfb83850db343.tar.gz rails-0d6e8edc2a47a4b4c6824936632bfb83850db343.tar.bz2 rails-0d6e8edc2a47a4b4c6824936632bfb83850db343.zip |
Move actionpack/lib/action_view* into actionview/lib
Diffstat (limited to 'actionpack/lib/action_view/helpers/tags/collection_helpers.rb')
-rw-r--r-- | actionpack/lib/action_view/helpers/tags/collection_helpers.rb | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/actionpack/lib/action_view/helpers/tags/collection_helpers.rb b/actionpack/lib/action_view/helpers/tags/collection_helpers.rb deleted file mode 100644 index 388dcf1f13..0000000000 --- a/actionpack/lib/action_view/helpers/tags/collection_helpers.rb +++ /dev/null @@ -1,84 +0,0 @@ -module ActionView - module Helpers - module Tags # :nodoc: - module CollectionHelpers # :nodoc: - class Builder # :nodoc: - attr_reader :object, :text, :value - - def initialize(template_object, object_name, method_name, object, - sanitized_attribute_name, text, value, input_html_options) - @template_object = template_object - @object_name = object_name - @method_name = method_name - @object = object - @sanitized_attribute_name = sanitized_attribute_name - @text = text - @value = value - @input_html_options = input_html_options - end - - def label(label_html_options={}, &block) - @template_object.label(@object_name, @sanitized_attribute_name, @text, label_html_options, &block) - end - end - - def initialize(object_name, method_name, template_object, collection, value_method, text_method, options, html_options) - @collection = collection - @value_method = value_method - @text_method = text_method - @html_options = html_options - - super(object_name, method_name, template_object, options) - end - - private - - def instantiate_builder(builder_class, item, value, text, html_options) - builder_class.new(@template_object, @object_name, @method_name, item, - sanitize_attribute_name(value), text, value, html_options) - end - - # Generate default options for collection helpers, such as :checked and - # :disabled. - def default_html_options_for_collection(item, value) #:nodoc: - html_options = @html_options.dup - - [:checked, :selected, :disabled].each do |option| - current_value = @options[option] - next if current_value.nil? - - accept = if current_value.respond_to?(:call) - current_value.call(item) - else - Array(current_value).map(&:to_s).include?(value.to_s) - end - - if accept - html_options[option] = true - elsif option == :checked - html_options[option] = false - end - end - - html_options[:object] = @object - html_options - end - - def sanitize_attribute_name(value) #:nodoc: - "#{sanitized_method_name}_#{sanitized_value(value)}" - end - - def render_collection #:nodoc: - @collection.map do |item| - value = value_for_collection(item, @value_method) - text = value_for_collection(item, @text_method) - default_html_options = default_html_options_for_collection(item, value) - additional_html_options = option_html_attributes(item) - - yield item, value, text, default_html_options.merge(additional_html_options) - end.join.html_safe - end - end - end - end -end |