Class: Challah::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/challah/engine.rb

Class Method Summary collapse

Class Method Details

.setup_action_controller!Object

Set up controller methods



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/challah/engine.rb', line 21

def self.setup_action_controller!
  if defined?(ActionController)
    ActionController::Base.send(:include, Challah::Controller)
    ActionController::Base.send(:helper_method,
      :current_user_session,
      :current_user,
      :current_user?,
      :logged_in?,
      :signed_in?
    )

    # Rails 5 API
    if defined?(ActionController::API)
      ActionController::API.send(:include, Challah::Controller)
    end

    # Load any ActionController/Challah plugins
    Challah.plugins.values.each do |plugin|
      plugin.action_controller.each do |proc|
        proc.call
      end
    end
  end
end

.setup_active_record!Object

Set up active record with Challah methods



47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/challah/engine.rb', line 47

def self.setup_active_record!
  if defined?(ActiveRecord)
    Challah.options[:logger] = ActiveRecord::Base.logger

    ActiveRecord::Base.send(:include, Challah::Audit)

    # Load any ActiveRecord/Challah plugins
    Challah.plugins.values.each do |plugin|
      plugin.active_record.each do |proc|
        proc.call
      end
    end
  end
end