Module: HatTrick::ControllerHooks

Extended by:
ActiveSupport::Concern
Includes:
ControllerHelpers
Defined in:
lib/hat_trick/controller_hooks.rb

Class Method Summary collapse

Class Method Details

.def_action_method_aliases(action_methods) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/hat_trick/controller_hooks.rb', line 13

def self.def_action_method_aliases(action_methods)
  action_methods.each do |meth|
    unless respond_to?(:"#{meth}_with_hat_trick")
      Rails.logger.debug "Defining #{meth}_with_hat_trick"
      module_eval <<-RUBY_EVAL
        def #{meth}_with_hat_trick(*args)
          Rails.logger.debug "#{meth}_with_hat_trick called"
          if respond_to?("#{meth}_hook", :include_private)
            #{meth}_hook(*args)
          end
          common_hook(*args) if respond_to?(:common_hook, :include_private)
          #{meth}_without_hat_trick(*args)
          if hat_trick_wizard.model && hat_trick_wizard.model.respond_to?(:disable_validation_groups)
            hat_trick_wizard.model.disable_validation_groups
          end
        end
        private "#{meth}_with_hat_trick"
      RUBY_EVAL
    end
  end
  true
end