module AUStateSelect::TagHelper

Public Instance Methods

state_option_tags() click to toggle source
# File lib/au_state_select/tag_helper.rb, line 3
def state_option_tags
  # In Rails 5.2+, `value` accepts no arguments and must also be called
  # called with parens to avoid the local variable of the same name
  # https://github.com/rails/rails/pull/29791
  selected_option = @options.fetch(:selected) do
    if self.method(:value).arity == 0
      value()
    else
      value(@object)
    end
  end

  option_tags_options = {
    :selected => selected_option,
    :disabled => @options[:disabled]
  }
  option_tags = options_for_select(state_options, option_tags_options)
end

Private Instance Methods

except_country_codes() click to toggle source
# File lib/au_state_select/tag_helper.rb, line 39
def except_country_codes
  @options[:except]
end
format() click to toggle source
# File lib/au_state_select/tag_helper.rb, line 43
def format
  @options[:format] || :default
end
html_safe_newline() click to toggle source
# File lib/au_state_select/tag_helper.rb, line 55
def html_safe_newline
  "\n".html_safe
end
locale() click to toggle source
# File lib/au_state_select/tag_helper.rb, line 23
def locale
  @options[:locale]
end
only_country_codes() click to toggle source
# File lib/au_state_select/tag_helper.rb, line 35
def only_country_codes
  @options[:only]
end
priority_countries_divider() click to toggle source
# File lib/au_state_select/tag_helper.rb, line 31
def priority_countries_divider
  @options[:priority_countries_divider] || "-"*15
end
priority_states() click to toggle source
# File lib/au_state_select/tag_helper.rb, line 27
def priority_states
  @options[:priority_states]
end
state_options() click to toggle source
# File lib/au_state_select/tag_helper.rb, line 47
def state_options
  if @options.key?(:short_name) && @options[:short_name]
    ['ACT', 'NSW', 'NT', 'QLD', 'SA', 'TAS', 'VIC', 'WA']
  else
    [['Australian Capital Territory', 'ACT'],['New South Wales', 'NSW'],['Northern Territory', 'NT'],['Queensland', 'QLD'],['South Australia', 'SA'],['Tasmania', 'TAS'],['Victoria', 'VIC'],['Western Australia', 'WA']]
  end
end