Sha256: ff191cacfc133d6722cf46ad14638a21045abf2978b90fc0372b58d079b9ddb2

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

module ActionView
  module Helpers
    class FormBuilder
      def country_select(method, priority_or_options = {}, options = {}, html_options = {})
        if priority_or_options.is_a? Hash
          html_options = options
          options = priority_or_options
        else
          if RUBY_VERSION =~ /^3\.\d\.\d/
            warn 'DEPRECATION WARNING: Setting priority countries with the 1.x syntax is deprecated. \
                  Please use the `priority_countries:` option.', uplevel: 1, category: :deprecated
          else
            warn 'DEPRECATION WARNING: Setting priority countries with the 1.x syntax is deprecated. \
                  Please use the `priority_countries:` option.', uplevel: 1
          end
          options[:priority_countries] = priority_or_options
        end

        @template.country_select(@object_name, method, objectify_options(options), @default_options.merge(html_options))
      end
    end

    module FormOptionsHelper
      def country_select(object, method, options = {}, html_options = {})
        Tags::CountrySelect.new(object, method, self, options, html_options).render
      end
    end

    module Tags
      class CountrySelect < Base
        include ::CountrySelect::TagHelper

        def initialize(object_name, method_name, template_object, options, html_options)
          @html_options = html_options

          super(object_name, method_name, template_object, options)
        end

        def render
          select_content_tag(country_option_tags, @options, @html_options)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
country_select-8.0.3 lib/country_select/country_select_helper.rb