File: active_model.rb

package info (click to toggle)
ruby-shoulda-matchers 7.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,652 kB
  • sloc: ruby: 34,046; sh: 280; makefile: 9
file content (39 lines) | stat: -rw-r--r-- 773 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require_relative '../model_creators'
require 'forwardable'

module UnitTests
  module ModelCreators
    class ActiveModel
      def self.call(args)
        new(args).call
      end

      extend Forwardable

      def_delegators(
        :arguments,
        :attribute_name,
        :attribute_default_values_by_name,
      )

      def initialize(args)
        @arguments = CreateModelArguments::Basic.wrap(
          args.merge!(
            model_creation_strategy: UnitTests::ModelCreationStrategies::ActiveModel,
          ),
        )
        @model_creator = Basic.new(arguments)
      end

      def call
        model_creator.call
      end

      protected

      attr_reader :arguments, :model_creator
    end

    register(:active_model, ActiveModel)
  end
end