Sha256: 9e45f85630c26d0b3b6397570b833430d9bf4b9e8a32d42c9dfa668ffef2108f
Contents?: true
Size: 894 Bytes
Versions: 12
Compression:
Stored size: 894 Bytes
Contents
module GovukPublishingComponents module Presenters class SelectHelper attr_reader :options, :option_markup, :selected_option def initialize(options) @options = options @option_markup = get_options end private def get_options return if options.nil? options.map { |option| @selected_option = option[:value] if option[:selected] [ option[:text], option[:value], options_data_attribute(option[:data_attributes]) ] } end def options_data_attribute(attributes) return {} if attributes.nil? attrs = {} attributes.each do |key, value| key_name = "data-#{key.to_s.split('_').join('-')}" attrs[key_name] = value.is_a?(Hash) ? value.to_json : value end attrs end end end end
Version data entries
12 entries across 12 versions & 1 rubygems