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

Injector.inject()   A

Complexity

Conditions 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 2
1
# frozen_string_literal: true
2
3
require_relative '../injector'
4
require_relative '../../mixin/reflection'
5
6
module AMA
7
  module Entity
8
    class Mapper
9
      module API
10
        module Default
11
          # Default attribute injector
12
          class Injector < API::Injector
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::Type::Attribute] attribute
20
            # @param [Object] value
21
            # @param [AMA::Entity::Mapper::Context] _context
22
            def inject(entity, _type, attribute, value, _context = nil)
23
              return entity if attribute.virtual
24
              set_object_attribute(entity, attribute.name, value)
25
              entity
26
            end
27
          end
28
        end
29
      end
30
    end
31
  end
32
end
33