Class: Gitlab::Database::Migrations::Version
- Inherits:
-
Object
- Object
- Gitlab::Database::Migrations::Version
- Includes:
- Comparable
- Defined in:
- lib/gitlab/database/migrations/version.rb
Constant Summary collapse
- InvalidTypeError =
Class.new(StandardError)
- TYPE_VALUES =
{ regular: 0, post: 1 }.freeze
Instance Attribute Summary collapse
-
#milestone ⇒ Object
Returns the value of attribute milestone.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#type_value ⇒ Object
readonly
Returns the value of attribute type_value.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #coerce(_) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(timestamp, milestone, type) ⇒ Version
constructor
A new instance of Version.
- #post_deployment? ⇒ Boolean
- #regular? ⇒ Boolean
- #to_i ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
- #type=(value) ⇒ Object
Constructor Details
Instance Attribute Details
#milestone ⇒ Object
Returns the value of attribute milestone.
16 17 18 |
# File 'lib/gitlab/database/migrations/version.rb', line 16 def milestone @milestone end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
16 17 18 |
# File 'lib/gitlab/database/migrations/version.rb', line 16 def @timestamp end |
#type_value ⇒ Object (readonly)
Returns the value of attribute type_value.
16 17 18 |
# File 'lib/gitlab/database/migrations/version.rb', line 16 def type_value @type_value end |
Instance Method Details
#<=>(other) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/gitlab/database/migrations/version.rb', line 44 def <=>(other) return 0 if other.is_a?(Integer) && @timestamp == other return 1 unless other.is_a?(self.class) compare_milestones = milestone <=> other.milestone return compare_milestones if compare_milestones != 0 return @type_value <=> other.type_value if @type_value != other.type_value @timestamp <=> other. end |
#==(other) ⇒ Object
73 74 75 |
# File 'lib/gitlab/database/migrations/version.rb', line 73 def ==(other) eql?(other) end |
#coerce(_) ⇒ Object
65 66 67 |
# File 'lib/gitlab/database/migrations/version.rb', line 65 def coerce(_) [-1, .to_i] end |
#eql?(other) ⇒ Boolean
69 70 71 |
# File 'lib/gitlab/database/migrations/version.rb', line 69 def eql?(other) (self <=> other) == 0 end |
#hash ⇒ Object
77 78 79 |
# File 'lib/gitlab/database/migrations/version.rb', line 77 def hash .hash end |
#post_deployment? ⇒ Boolean
40 41 42 |
# File 'lib/gitlab/database/migrations/version.rb', line 40 def post_deployment? @type_value == TYPE_VALUES[:post] end |
#regular? ⇒ Boolean
36 37 38 |
# File 'lib/gitlab/database/migrations/version.rb', line 36 def regular? @type_value == TYPE_VALUES[:regular] end |
#to_i ⇒ Object
61 62 63 |
# File 'lib/gitlab/database/migrations/version.rb', line 61 def to_i @timestamp.to_i end |
#to_s ⇒ Object
57 58 59 |
# File 'lib/gitlab/database/migrations/version.rb', line 57 def to_s @timestamp.to_s end |
#type ⇒ Object
24 25 26 |
# File 'lib/gitlab/database/migrations/version.rb', line 24 def type TYPE_VALUES.key(@type_value) end |
#type=(value) ⇒ Object
28 29 30 |
# File 'lib/gitlab/database/migrations/version.rb', line 28 def type=(value) @type_value = TYPE_VALUES.fetch(value.to_sym) { raise InvalidTypeError } end |