lib/materialist/materializer/internals/materializer.rb in materialist-3.6.0 vs lib/materialist/materializer/internals/materializer.rb in materialist-3.7.0

- old
+ new

@@ -59,10 +59,11 @@ end def upsert_record model_class.find_or_initialize_by(source_lookup(url)).tap do |entity| send_messages(before_upsert, entity) unless before_upsert.nil? + before_upsert_with_payload&.each { |m| instance.send(m, entity, resource) } entity.update_attributes!(attributes) end end def materialize_links @@ -72,19 +73,22 @@ def materialize_link(key, opts) return unless link = resource.dig(:_links, key) return unless materializer_class = MaterializerFactory.class_from_topic(opts.fetch(:topic)) - # TODO: perhaps consider doing this asynchronously some how? materializer_class.perform(link[:href], :noop) end def mappings options.fetch :mapping end def before_upsert options[:before_upsert] + end + + def before_upsert_with_payload + options[:before_upsert_with_payload] end def after_upsert options[:after_upsert] end