Module: Viewable::Field::UUID

Extended by:
ActiveSupport::Concern
Included in:
Block, Viewable::Form, Page
Defined in:
app/models/viewable/field/uuid.rb

Instance Method Summary collapse

Instance Method Details

#other_uuid(locale) ⇒ Object



38
39
40
# File 'app/models/viewable/field/uuid.rb', line 38

def other_uuid(locale)
  self.class.localized(locale).where(uuid: uuid).first
end

#uuidObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/viewable/field/uuid.rb', line 20

def uuid
  value = read_attribute(:uuid)
  if value.blank?
    value = SecureRandom.uuid
    transaction do
      update_uuid_columns value
      other_locales.each do |viewable|
        viewable.__send__ :update_uuid_columns, value
      end
    end
  end
  value
end

#uuid_with(name) ⇒ Object



34
35
36
# File 'app/models/viewable/field/uuid.rb', line 34

def uuid_with(name)
  "#{self.class.uuid_prefix}[#{uuid}]/#{name}"
end