Entity.eql?   A
last analyzed

Complexity

Conditions 4

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
c 1
b 0
f 0
dl 0
loc 9
rs 9.2
1
# frozen_string_literal: true
2
3
require 'ama-entity-mapper'
4
5
module AMA
6
  module Chef
7
    module User
8
      module Mixin
9
        # Base methods for entities (models) used across project
10
        module Entity
11
          class << self
12
            def included(klass)
13
              klass.send(:include, AMA::Entity::Mapper::DSL)
14
            end
15
          end
16
17
          def ==(other)
18
            eql?(other)
19
          end
20
21
          def eql?(other)
22
            return false unless other.is_a?(self.class) || is_a?(other.class)
23
            return false unless other.instance_variables == instance_variables
24
            instance_variables.each do |variable|
25
              value = other.instance_variable_get(variable)
26
              return false unless instance_variable_get(variable) == value
27
            end
28
            true
29
          end
30
        end
31
      end
32
    end
33
  end
34
end
35