Module: ConcernsOnRails::Hashable

Extended by:
ActiveSupport::Concern
Defined in:
lib/concerns_on_rails/hashable.rb

Constant Summary collapse

VALID_TYPES =
%i[hex uuid integer custom].freeze

Instance Method Summary collapse

Instance Method Details

#assign_hashable_valueObject

Assigns the generated value only when the field is blank, so callers can still pass an explicit value at create time.



70
71
72
73
74
75
# File 'lib/concerns_on_rails/hashable.rb', line 70

def assign_hashable_value
  field = self.class.hashable_field
  return if self[field].present?

  self[field] = self.class.generate_hashable_value
end