Class: MegaBar::Field
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- MegaBar::Field
- Defined in:
- app/models/mega_bar/field.rb
Instance Attribute Summary collapse
-
#block_id ⇒ Object
Returns the value of attribute block_id.
-
#edit_field_display ⇒ Object
Returns the value of attribute edit_field_display.
-
#index_field_display ⇒ Object
Returns the value of attribute index_field_display.
-
#model_display_ids ⇒ Object
Returns the value of attribute model_display_ids.
-
#new_field_display ⇒ Object
Returns the value of attribute new_field_display.
-
#show_field_display ⇒ Object
Returns the value of attribute show_field_display.
Class Method Summary collapse
-
.deterministic_id(name, field_type, model_id = nil) ⇒ Object
Deterministic ID generation for Fields ID range: 1000-1999.
Instance Attribute Details
#block_id ⇒ Object
Returns the value of attribute block_id.
6 7 8 |
# File 'app/models/mega_bar/field.rb', line 6 def block_id @block_id end |
#edit_field_display ⇒ Object
Returns the value of attribute edit_field_display.
6 7 8 |
# File 'app/models/mega_bar/field.rb', line 6 def edit_field_display @edit_field_display end |
#index_field_display ⇒ Object
Returns the value of attribute index_field_display.
6 7 8 |
# File 'app/models/mega_bar/field.rb', line 6 def index_field_display @index_field_display end |
#model_display_ids ⇒ Object
Returns the value of attribute model_display_ids.
6 7 8 |
# File 'app/models/mega_bar/field.rb', line 6 def model_display_ids @model_display_ids end |
#new_field_display ⇒ Object
Returns the value of attribute new_field_display.
6 7 8 |
# File 'app/models/mega_bar/field.rb', line 6 def new_field_display @new_field_display end |
#show_field_display ⇒ Object
Returns the value of attribute show_field_display.
6 7 8 |
# File 'app/models/mega_bar/field.rb', line 6 def show_field_display @show_field_display end |
Class Method Details
.deterministic_id(name, field_type, model_id = nil) ⇒ Object
Deterministic ID generation for Fields ID range: 1000-1999
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/mega_bar/field.rb', line 19 def self.deterministic_id(name, field_type, model_id = nil) # Include model_id to make fields unique per model identifier = model_id ? "#{name}_#{field_type}_#{model_id}" : "#{name}_#{field_type}" hash = Digest::MD5.hexdigest(identifier) base_id = 1000 + (hash.to_i(16) % 1000) # Check for collisions and increment if needed while MegaBar::Field.exists?(id: base_id) base_id += 1 break if base_id >= 2000 # Don't overflow into next range end base_id end |