Class: MegaBar::Date

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.deterministic_id(field_display_id) ⇒ Object

Deterministic ID generation for Date UI Components ID range: 28000-28999



22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/mega_bar/date.rb', line 22

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

Instance Method Details

#controller_nameObject



16
17
18
# File 'app/models/mega_bar/date.rb', line 16

def controller_name
  'mega_bar/dates'
end

#get_model_idObject



12
13
14
# File 'app/models/mega_bar/date.rb', line 12

def get_model_id
  9777
end