Class: Snowflaked::Configuration
- Inherits:
-
Object
- Object
- Snowflaked::Configuration
- Defined in:
- lib/snowflaked.rb
Instance Attribute Summary collapse
-
#epoch ⇒ Object
Returns the value of attribute epoch.
-
#machine_id ⇒ Object
Returns the value of attribute machine_id.
Instance Method Summary collapse
- #epoch_ms ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #machine_id_value ⇒ Object
- #seal! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
27 28 29 30 31 |
# File 'lib/snowflaked.rb', line 27 def initialize @machine_id = nil @epoch = DEFAULT_EPOCH @sealed = false end |
Instance Attribute Details
#epoch ⇒ Object
Returns the value of attribute epoch.
25 26 27 |
# File 'lib/snowflaked.rb', line 25 def epoch @epoch end |
#machine_id ⇒ Object
Returns the value of attribute machine_id.
25 26 27 |
# File 'lib/snowflaked.rb', line 25 def machine_id @machine_id end |
Instance Method Details
#epoch_ms ⇒ Object
61 62 63 64 65 |
# File 'lib/snowflaked.rb', line 61 def epoch_ms return nil unless @epoch @epoch_ms ||= (@epoch.to_r * 1000).to_i end |
#machine_id_value ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/snowflaked.rb', line 52 def machine_id_value if @machine_id_value_pid != Process.pid @machine_id_value = resolve_machine_id @machine_id_value_pid = Process.pid end @machine_id_value end |
#seal! ⇒ Object
48 49 50 |
# File 'lib/snowflaked.rb', line 48 def seal! @sealed = true end |