Any.==()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
1
# frozen_string_literal: true
2
3
require_relative '../type'
4
require_relative '../mixin/errors'
5
6
module AMA
7
  module Entity
8
    class Mapper
9
      class Type
10
        # Used as a wildcard to pass anything through
11
        class Any < Type
12
          include Mixin::Errors
13
14
          def initialize
15
            super(self.class)
16
            denormalizer_block { |entity, *| entity }
17
            normalizer_block { |entity, *| entity }
18
            validator_block { |*| [] }
19
          end
20
21
          INSTANCE = new
22
23
          def parameters
24
            {}
25
          end
26
27
          def attributes
28
            {}
29
          end
30
31
          def parameter!(*)
32
            compliance_error('Tried to declare parameter on Any type')
33
          end
34
35
          def resolve_parameter(*)
36
            self
37
          end
38
39
          def instance?(object, *)
40
            !object.nil?
41
          end
42
43
          def hash
44
            self.class.hash
45
          end
46
47
          def eql?(other)
48
            other.is_a?(Type)
49
          end
50
51
          def ==(other)
52
            eql?(other)
53
          end
54
55
          def to_s
56
            'Any Type'
57
          end
58
59
          def to_def
60
            '*'
61
          end
62
        end
63
      end
64
    end
65
  end
66
end
67