| Total Complexity | 11 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # frozen_string_literal: true |
||
| 13 | class Parameter |
||
| 14 | include Mixin::Errors |
||
| 15 | |||
| 16 | # @!attribute type |
||
| 17 | # @return [AMA::Entity::Mapper::Type] |
||
| 18 | attr_reader :owner |
||
| 19 | # @!attribute id |
||
| 20 | # @return [Symbol] |
||
| 21 | attr_reader :id |
||
| 22 | |||
| 23 | # @param [AMA::Entity::Mapper::Type] owner |
||
| 24 | # @param [Symbol] id |
||
| 25 | def initialize(owner, id) |
||
| 26 | @owner = owner |
||
| 27 | @id = id |
||
| 28 | end |
||
| 29 | |||
| 30 | def instance?(_) |
||
| 31 | false |
||
| 32 | end |
||
| 33 | |||
| 34 | def resolve_parameter(*) |
||
| 35 | self |
||
| 36 | end |
||
| 37 | |||
| 38 | def resolved? |
||
| 39 | false |
||
| 40 | end |
||
| 41 | |||
| 42 | def resolved!(context = nil) |
||
| 43 | compliance_error("Type #{self} is not resolved", context: context) |
||
| 44 | end |
||
| 45 | |||
| 46 | def to_s |
||
| 47 | "Parameter #{owner.type}.#{id}" |
||
| 48 | end |
||
| 49 | |||
| 50 | def to_def |
||
| 51 | "#{owner.type}.#{id}" |
||
| 52 | end |
||
| 53 | |||
| 54 | def hash |
||
| 55 | @owner.hash ^ @id.hash |
||
| 56 | end |
||
| 57 | |||
| 58 | def eql?(other) |
||
| 59 | return false unless other.is_a?(self.class) |
||
| 60 | @id == other.id && @owner == other.owner |
||
| 61 | end |
||
| 62 | |||
| 63 | def ==(other) |
||
| 64 | eql?(other) |
||
| 65 | end |
||
| 66 | end |
||
| 67 | end |
||
| 71 |