53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/nomo/model.rb', line 53
def modifies(association, name, options = {})
options = Nomo.default_options.merge(options)
modify_page_method = :"modify_#{association}_#{name}_page"
define_method modify_page_method do
for record in [*send(association)]
page = record.send(:"#{name}_page")
page.modify(modified_by: self)
end
end
after_create modify_page_method, options.fetch(:create, {}) unless options.has_key?(:on) && ![*options[:on]].include?(:create)
after_update modify_page_method, options.fetch(:update, {}) unless options.has_key?(:on) && ![*options[:on]].include?(:update)
after_destroy modify_page_method, options.fetch(:destroy, {}) unless options.has_key?(:on) && ![*options[:on]].include?(:destroy)
after_touch modify_page_method, options.fetch(:touch, {}) unless options.has_key?(:on) && ![*options[:on]].include?(:touch)
end
|