2025-10-29 15:05:18 +01:00
|
|
|
require 'pp'
|
|
|
|
|
|
2025-10-29 10:47:55 +01:00
|
|
|
Rails.application.config.to_prepare do
|
|
|
|
|
Model # Zeitwerk autoload model
|
2025-10-29 15:05:18 +01:00
|
|
|
ModelFile
|
2025-10-29 10:47:55 +01:00
|
|
|
|
2025-10-29 15:05:18 +01:00
|
|
|
# extend by adding listeners
|
2025-10-29 10:47:55 +01:00
|
|
|
class Model
|
|
|
|
|
# The 'after_save' macro is now run within the context of the existing Model class.
|
2025-10-29 15:05:18 +01:00
|
|
|
after_commit :run_cli_hooks
|
2025-10-29 10:47:55 +01:00
|
|
|
|
|
|
|
|
# Define the new method to be executed on save.
|
2025-10-29 15:05:18 +01:00
|
|
|
def run_cli_hooks
|
2025-10-29 10:47:55 +01:00
|
|
|
# Your custom logic to execute after Model.save or Model.update! goes here.
|
|
|
|
|
|
|
|
|
|
# 📝 Example Logic:
|
2025-10-29 15:05:18 +01:00
|
|
|
puts "\n-------- MODEL --------- #{self.id}\n\n"
|
|
|
|
|
pp self
|
|
|
|
|
puts "\n\n"
|
|
|
|
|
|
|
|
|
|
command = "pwd"
|
|
|
|
|
system(command)
|
|
|
|
|
|
2025-10-29 10:47:55 +01:00
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|