thoughtbot/factory_girl

View on GitHub
lib/factory_bot/decorator/attribute_hash.rb

Summary

Maintainability
A
0 mins
Test Coverage
module FactoryBot
  class Decorator
    class AttributeHash < Decorator
      def initialize(component, attributes = [])
        super(component)
        @attributes = attributes
      end

      def attributes
        @attributes.each_with_object({}) do |attribute_name, result|
          result[attribute_name] = @component.send(attribute_name)
        end
      end
    end
  end
end