Completed
Push — dev ( 36eb97...6cb2fc )
by Fike
01:01
created

Normalizer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 6 1
1
# frozen_string_literal: true
2
3
require_relative '../normalizer'
4
require_relative '../../mixin/reflection'
5
6
module AMA
7
  module Entity
8
    class Mapper
9
      module API
10
        module Default
11
          # Default denormalization processor
12
          class Normalizer < API::Normalizer
13
            include Mixin::Reflection
14
15
            INSTANCE = new
16
17
            # @param [Object] entity
18
            # @param [AMA::Entity::Mapper::Type] type
19
            # @param [AMA::Entity::Mapper::Context] _context
20
            def normalize(entity, type, _context = nil)
21
              type.attributes.values.each_with_object({}) do |attribute, data|
22
                next if attribute.virtual || attribute.sensitive
23
                data[attribute.name] = object_variable(entity, attribute.name)
24
              end
25
            end
26
          end
27
        end
28
      end
29
    end
30
  end
31
end
32