Sha256: 24670de28ce24b55226952116e148e0957eb2b6246b45dda8cb231ae29bd8297
Contents?: true
Size: 683 Bytes
Versions: 4
Compression:
Stored size: 683 Bytes
Contents
class Dynomite::Item module Id extend ActiveSupport::Concern included do field :id before_save :set_id end def set_id return if self.class.disable_id? self.id ||= generate_id end def generate_id "#{id_prefix}-#{SecureRandom.alphanumeric(16)}" end def id_prefix self.class.id_prefix_value end class_methods do def disable_id? !!@disable_id end def disable_id! @disable_id = true end def id_prefix(value=nil) if value.nil? self.id_prefix_value else self.id_prefix_value = value end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dynomite-2.0.3 | lib/dynomite/item/id.rb |
dynomite-2.0.2 | lib/dynomite/item/id.rb |
dynomite-2.0.1 | lib/dynomite/item/id.rb |
dynomite-2.0.0 | lib/dynomite/item/id.rb |