Module: IdRegistryHelper
- Included in:
- ScavengerHunt::ApplicationHelper
- Defined in:
- app/helpers/id_registry_helper.rb
Overview
IDRegistryHelper ensures no ID's overlap on the page by keeping track of those that have been generated and providing iterations to them as things move forward
Instance Method Summary collapse
Instance Method Details
#id_for(string) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'app/helpers/id_registry_helper.rb', line 9 def id_for(string) original_id = id = string.parameterize i = 0 while ids.include? id i = i.succ id = "#{original_id}-#{i}" end ids.add(id) id end |
#ids ⇒ Object
5 6 7 |
# File 'app/helpers/id_registry_helper.rb', line 5 def ids @ids ||= Set.new end |