Class: ActiveRecord::ConnectionAdapters::MasterSlaveAdapter::Clock
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::MasterSlaveAdapter::Clock
- Includes:
- Comparable
- Defined in:
- lib/active_record/connection_adapters/master_slave_adapter/clock.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #infinity? ⇒ Boolean
-
#initialize(file, position) ⇒ Clock
constructor
A new instance of Clock.
- #to_s ⇒ Object
Constructor Details
#initialize(file, position) ⇒ Clock
Returns a new instance of Clock.
8 9 10 11 |
# File 'lib/active_record/connection_adapters/master_slave_adapter/clock.rb', line 8 def initialize(file, position) raise ArgumentError, "file and postion may not be nil" if file.nil? || position.nil? @file, @position = file, position.to_i end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
6 7 8 |
# File 'lib/active_record/connection_adapters/master_slave_adapter/clock.rb', line 6 def file @file end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
6 7 8 |
# File 'lib/active_record/connection_adapters/master_slave_adapter/clock.rb', line 6 def position @position end |
Class Method Details
.infinity ⇒ Object
29 30 31 |
# File 'lib/active_record/connection_adapters/master_slave_adapter/clock.rb', line 29 def self.infinity @infinity ||= Clock.new('', Float::MAX.to_i) end |
.parse(string) ⇒ Object
33 34 35 36 37 |
# File 'lib/active_record/connection_adapters/master_slave_adapter/clock.rb', line 33 def self.parse(string) new(*string.split('@')) rescue nil end |
Instance Method Details
#<=>(other) ⇒ Object
13 14 15 |
# File 'lib/active_record/connection_adapters/master_slave_adapter/clock.rb', line 13 def <=>(other) @file == other.file ? @position <=> other.position : @file <=> other.file end |
#infinity? ⇒ Boolean
21 22 23 |
# File 'lib/active_record/connection_adapters/master_slave_adapter/clock.rb', line 21 def infinity? self == self.class.infinity end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/active_record/connection_adapters/master_slave_adapter/clock.rb', line 17 def to_s [ @file, @position ].join('@') end |