Sha256: 2f40f3e2a3d7f80d571a7ce53c88afd5391828f8f8b01323e4fb8750c53565b3
Contents?: true
Size: 799 Bytes
Versions: 59
Compression:
Stored size: 799 Bytes
Contents
# frozen_string_literal: true module Alchemy module DomIds extend ActiveSupport::Concern RESERVED_ANCHOR_SETTING_VALUES = %w[false from_value true] included do before_validation :parameterize_dom_id, if: -> { settings[:anchor].to_s == "true" } before_validation :set_dom_id_from_value, if: -> { settings[:anchor].to_s == "from_value" } before_validation :set_dom_id_to_fixed_value, if: -> { !RESERVED_ANCHOR_SETTING_VALUES.include? settings[:anchor].to_s } end private def parameterize_dom_id self.dom_id = dom_id&.parameterize end def set_dom_id_from_value self.dom_id = value&.parameterize end def set_dom_id_to_fixed_value self.dom_id = settings[:anchor]&.parameterize end end end
Version data entries
59 entries across 59 versions & 1 rubygems