Move action callbacks to action class
Dieser Commit ist enthalten in:
Ursprung
26749bd055
Commit
aa288b19e2
2 geänderte Dateien mit 14 neuen und 9 gelöschten Zeilen
|
@ -43,10 +43,14 @@ class CustomWizard::Action
|
|||
@mapper ||= CustomWizard::Mapper.new(user: user, data: mapper_data)
|
||||
end
|
||||
|
||||
def callbacks_for(action)
|
||||
self.class.callbacks[action] || []
|
||||
end
|
||||
|
||||
def create_topic
|
||||
params = basic_topic_params.merge(public_topic_params)
|
||||
|
||||
CustomWizard::Field.action_callbacks.each do |acb|
|
||||
callbacks_for(:before_create_topic).each do |acb|
|
||||
params = acb.call(params, @wizard, @action, @submission)
|
||||
end
|
||||
|
||||
|
@ -421,6 +425,15 @@ class CustomWizard::Action
|
|||
end
|
||||
end
|
||||
|
||||
def self.callbacks
|
||||
@callbacks ||= {}
|
||||
end
|
||||
|
||||
def self.register_callback(action, &block)
|
||||
callbacks[action] ||= []
|
||||
callbacks[action] << block
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def action_category
|
||||
|
|
|
@ -131,10 +131,6 @@ class CustomWizard::Field
|
|||
}
|
||||
end
|
||||
|
||||
def self.action_callbacks
|
||||
@acbs ||= []
|
||||
end
|
||||
|
||||
def self.require_assets
|
||||
Rails.logger.warn("Custom Wizard field regisration no longer requires asset registration. Support will be removed in v2.1.0.")
|
||||
|
||||
|
@ -153,9 +149,5 @@ class CustomWizard::Field
|
|||
types[type.to_sym] ||= {}
|
||||
types[type.to_sym] = opts[:type_opts] if opts[:type_opts].present?
|
||||
end
|
||||
|
||||
if opts[:action_callback].present? && opts[:action_callback].is_a?(Proc)
|
||||
action_callbacks << opts[:action_callback]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Laden …
In neuem Issue referenzieren