Class: Natsuzora::Contract::TypeDef
- Inherits:
-
Object
- Object
- Natsuzora::Contract::TypeDef
- Defined in:
- lib/natsuzora/contract/type_def.rb
Overview
A type definition with optional diff marker.
Instance Attribute Summary collapse
-
#contract ⇒ Object
readonly
Returns the value of attribute contract.
-
#marker ⇒ Object
readonly
Returns the value of attribute marker.
Instance Method Summary collapse
-
#available?(target) ⇒ Boolean
Check if this type is available for the specified target.
-
#initialize(contract, marker: nil) ⇒ TypeDef
constructor
A new instance of TypeDef.
Constructor Details
#initialize(contract, marker: nil) ⇒ TypeDef
Returns a new instance of TypeDef.
12 13 14 15 |
# File 'lib/natsuzora/contract/type_def.rb', line 12 def initialize(contract, marker: nil) @marker = marker @contract = contract end |
Instance Attribute Details
#contract ⇒ Object (readonly)
Returns the value of attribute contract.
10 11 12 |
# File 'lib/natsuzora/contract/type_def.rb', line 10 def contract @contract end |
#marker ⇒ Object (readonly)
Returns the value of attribute marker.
10 11 12 |
# File 'lib/natsuzora/contract/type_def.rb', line 10 def marker @marker end |
Instance Method Details
#available?(target) ⇒ Boolean
Check if this type is available for the specified target. NOTE: Diff resolution table here mirrors Field#for_target — keep in sync.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/natsuzora/contract/type_def.rb', line 19 def available?(target) # rubocop:disable Lint/DuplicateBranch case [@marker, target] in [nil, _] true in [DiffMarker::ADDED, ValidationTarget::CURRENT] false in [DiffMarker::ADDED, ValidationTarget::NEXT] true in [DiffMarker::REMOVED, ValidationTarget::CURRENT] true in [DiffMarker::REMOVED, ValidationTarget::NEXT] false in [DiffMarker::CHANGED, _] false # Changed not allowed for type defs end # rubocop:enable Lint/DuplicateBranch end |