Class: Avrolution::CompatibilityBreak

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/avrolution/compatibility_break.rb

Constant Summary collapse

ValidationError =
Class.new(StandardError)
VALID_COMPATIBILITY_VALUES =
%w(BACKWARD BACKWARD_TRANSITIVE FORWARD
FORWARD_TRANSITIVE FULL FULL_TRANSITIVE NONE).map(&:freeze).freeze
NONE =
'NONE'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, fingerprint, with_compatibility = NONE, after_compatibility = nil, *extra) ⇒ CompatibilityBreak

Returns a new instance of CompatibilityBreak.



19
20
21
22
23
24
25
# File 'lib/avrolution/compatibility_break.rb', line 19

def initialize(name, fingerprint, with_compatibility = NONE, after_compatibility = nil, *extra)
  @name = name
  @fingerprint = fingerprint
  @with_compatibility = with_compatibility.upcase
  @after_compatibility = after_compatibility.try(:upcase)
  @extra = extra
end

Instance Attribute Details

#after_compatibilityObject (readonly)

Returns the value of attribute after_compatibility.



13
14
15
# File 'lib/avrolution/compatibility_break.rb', line 13

def after_compatibility
  @after_compatibility
end

#fingerprintObject (readonly)

Returns the value of attribute fingerprint.



13
14
15
# File 'lib/avrolution/compatibility_break.rb', line 13

def fingerprint
  @fingerprint
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/avrolution/compatibility_break.rb', line 13

def name
  @name
end

#with_compatibilityObject (readonly)

Returns the value of attribute with_compatibility.



13
14
15
# File 'lib/avrolution/compatibility_break.rb', line 13

def with_compatibility
  @with_compatibility
end

Instance Method Details

#keyObject



27
28
29
# File 'lib/avrolution/compatibility_break.rb', line 27

def key
  [name, fingerprint]
end

#lineObject



35
36
37
# File 'lib/avrolution/compatibility_break.rb', line 35

def line
  [name, fingerprint, with_compatibility, after_compatibility].compact.join(' ')
end

#validate!Object

Raises:



31
32
33
# File 'lib/avrolution/compatibility_break.rb', line 31

def validate!
  raise ValidationError.new(errors.full_messages.join(', ')) unless valid?
end