snowflaked 0.1.3-x86_64-linux → 0.1.4-x86_64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3403f879d3b0f5e3beab68b0bfb75f5578da558d3214609ce06dea36e77fcebe
4
- data.tar.gz: 6c436721cd068336302528481a341888966e9849c418dc559f012418a4dd1e37
3
+ metadata.gz: 3e9216284f7f936f6b46448befa6a565c869b74565d147e44aa15dbaf7353bf0
4
+ data.tar.gz: 94c5223161e2368fcef0a1ed238b0efbf94e91232d79298314027bc665343082
5
5
  SHA512:
6
- metadata.gz: 719aadc1bf0400f2c97ae7bc2afe94fa0f035031f9cd40876f3c9e5db4b71961d6105f173c6a7aae9140a11e886b2f304f106265f9f393d3e616be4427dddcc7
7
- data.tar.gz: '07397c563c26b9b49e3ebb2c9517bc19e0e0020175f4a5ef70b9c08465cf37ac3d6bc0b63fd9583fc6825a361fb18a0840faf351dabcbf7c1ec84003bccd3aaf'
6
+ metadata.gz: 54c386bee995bbc8e5ad5477a4d9fbde70774ae9dac69cbead6f545408be08dc1b432dfda75d1c786e9417c5a75e4d48656a0cd1e8922f3ef7132bd299f5a3b7
7
+ data.tar.gz: 5ed7c76486fc5ba5e0819683a378b6865b3bf3385a0120c3eeab54211a078826902edf03596561c40d44adc6df3999a962685a9fd869ffba9af50870a931a841
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Downloads](https://img.shields.io/gem/dt/snowflaked.svg)](https://rubygems.org/gems/snowflaked)
6
6
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.txt)
7
7
 
8
- A high-performance, thread-safe Snowflake ID generator for Ruby, powered by Rust.
8
+ A database-agnostic, high-performance, thread-safe Snowflake ID generator for Ruby, powered by Rust.
9
9
 
10
10
  Snowflake IDs are 64-bit unique identifiers that encode a timestamp, machine ID, and sequence number. They're time-sortable (IDs created later are always larger), making them ideal for distributed systems where you need unique IDs without coordination between machines. Unlike UUIDs, Snowflake IDs are smaller, sortable, and index-friendly for databases.
11
11
 
@@ -143,6 +143,12 @@ Snowflaked.machine_id(id)
143
143
  # => 42
144
144
  ```
145
145
 
146
+ ## Benchmarks
147
+
148
+ See [BENCHMARKS.md](benchmarks/BENCHMARKS.md) for more details.
149
+
150
+ tl;dr: Snowflake IDs have a negligible performance impact compared to database-backed IDs.
151
+
146
152
  ## Requirements
147
153
 
148
154
  - Ruby >= 3.2
Binary file
Binary file
Binary file
Binary file
@@ -6,7 +6,7 @@ module Snowflaked
6
6
 
7
7
  included do
8
8
  class_attribute :_snowflake_attributes, instance_writer: false, default: [:id]
9
- before_validation :_generate_snowflake_ids, on: :create
9
+ after_initialize :_generate_snowflake_ids, if: :new_record?
10
10
  end
11
11
 
12
12
  class_methods do
@@ -14,6 +14,7 @@ module Snowflaked
14
14
  attrs = attributes.map(&:to_sym)
15
15
  attrs |= [:id] if id
16
16
  self._snowflake_attributes = attrs
17
+ @_snowflake_attributes_with_columns = nil
17
18
  end
18
19
 
19
20
  def _snowflake_columns_from_comments
@@ -25,12 +26,17 @@ module Snowflaked
25
26
  []
26
27
  end
27
28
  end
29
+
30
+ def _snowflake_attributes_with_columns
31
+ @_snowflake_attributes_with_columns ||= (_snowflake_attributes | _snowflake_columns_from_comments)
32
+ end
28
33
  end
29
34
 
30
35
  private
31
36
 
32
37
  def _generate_snowflake_ids
33
- attributes_to_generate = self.class._snowflake_attributes | self.class._snowflake_columns_from_comments
38
+ attributes_to_generate = self.class._snowflake_attributes_with_columns
39
+ return if attributes_to_generate.empty?
34
40
 
35
41
  attributes_to_generate.each do |attribute|
36
42
  next if self[attribute].present?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Snowflaked
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snowflaked
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Luiz Eduardo Kowalski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-11 00:00:00.000000000 Z
11
+ date: 2026-01-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Ruby gem for generating Twitter Snowflake IDs using a high-performance
14
14
  Rust backend. Thread-safe with configurable machine ID and custom epoch support.