Class: MegaBar::Player

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.deterministic_id(field_display_id) ⇒ Object

Deterministic ID generation for Player UI Components ID range: 29000-29999



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/mega_bar/player.rb', line 14

def self.deterministic_id(field_display_id)
  identifier = "player_#{field_display_id}"
  hash = Digest::MD5.hexdigest(identifier)
  base_id = 29000 + (hash.to_i(16) % 1000)
  
  while self.exists?(id: base_id)
    base_id += 1
    break if base_id >= 30000
  end
  
  base_id
end

Instance Method Details

#controller_nameObject



32
33
34
# File 'app/models/mega_bar/player.rb', line 32

def controller_name
  'mega_bar/players'
end

#get_model_idObject



27
28
29
30
# File 'app/models/mega_bar/player.rb', line 27

def get_model_id
  # TODO: Set the correct model ID for Player
  9778  # This should be the Player model's deterministic ID
end