19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/alchemrest/factory_bot.rb', line 19
def alchemrest_factory(name, options = {}, &block)
raise ArgumentError, "You must specify a class" unless options[:class]
raise ArgumentError, "You must specify a block" unless block
factory(name, options) do
skip_create
initialize_with do
provided_attributes = attributes.reject { |_, v| v.is_a?(Alchemrest::FactoryBot::OmitKey) }
options[:class].constantize.from_hash(provided_attributes)
end
instance_eval(&block)
end
end
|