Class: MegaBar::Checkbox

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/mega_bar/checkbox.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.deterministic_id(field_display_id) ⇒ Object

Deterministic ID generation for Checkboxes ID range: 17000-17999



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/mega_bar/checkbox.rb', line 11

def self.deterministic_id(field_display_id)
  # Use field_display_id to create unique identifier
  identifier = "checkbox_#{field_display_id}"
  hash = Digest::MD5.hexdigest(identifier)
  base_id = 17000 + (hash.to_i(16) % 1000)
  
  # Check for collisions and increment if needed
  while MegaBar::Checkbox.exists?(id: base_id)
    base_id += 1
    break if base_id >= 18000  # Don't overflow into next range
  end
  
  base_id
end

Instance Method Details

#controller_nameObject



29
30
31
# File 'app/models/mega_bar/checkbox.rb', line 29

def controller_name
  'mega_bar/checkboxes'
end

#get_model_idObject



26
27
28
# File 'app/models/mega_bar/checkbox.rb', line 26

def get_model_id
  14
end