Class: Snowflaked::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/snowflaked.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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

#epochObject

Returns the value of attribute epoch.



25
26
27
# File 'lib/snowflaked.rb', line 25

def epoch
  @epoch
end

#machine_idObject

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_msObject



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_valueObject



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