Sha256: c16eaee238c4b24edc761cfad350520f1cff2df5d18f5a68f2917cde01a730f9

Contents?: true

Size: 537 Bytes

Versions: 9

Compression:

Stored size: 537 Bytes

Contents

module LazyCrud
  module BeforeHookMethods
    include Constants

    ACTIONS_WITH_HOOKS.each do |action|
      # runs all of the hooks
      define_method("run_before_#{action}_hooks") do
        hook_list = self.send("before_#{action}_hooks")

        if hook_list
          hook_list.each do |hook|
            hook.call(@resource)
          end
        end

        # run the before action method if it exists
        if respond_to?("before_#{action}")
          self.send("before_#{action}")
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lazy_crud-0.9.8.4 lib/lazy_crud/before_hook_methods.rb
lazy_crud-0.9.8.3 lib/lazy_crud/before_hook_methods.rb
lazy_crud-0.9.8.2 lib/lazy_crud/before_hook_methods.rb
lazy_crud-0.9.8.1 lib/lazy_crud/before_hook_methods.rb
lazy_crud-0.9.8.0 lib/lazy_crud/before_hook_methods.rb
lazy_crud-0.9.7.1 lib/lazy_crud/before_hook_methods.rb
lazy_crud-0.9.7 lib/lazy_crud/before_hook_methods.rb
lazy_crud-0.9.6 lib/lazy_crud/before_hook_methods.rb
lazy_crud-0.9.5 lib/lazy_crud/before_hook_methods.rb