Sha256: 40855c85b09690a504376bcc3e277bd43af8e3ae476259e7ccd21b556a971f14

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module ActionView
  module Helpers
    class FormBuilder
      def country_select(method, options = {}, html_options = {})
        unless options.is_a?(Hash)
          raise ArgumentError, 'Invalid syntax for country_select method. options must be a hash'
        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

3 entries across 3 versions & 1 rubygems

Version Path
country_select-10.0.1 lib/country_select/country_select_helper.rb
country_select-10.0.0 lib/country_select/country_select_helper.rb
country_select-9.0.0 lib/country_select/country_select_helper.rb