Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add one railtie to load the proper files depending of the frameworks
- Loading branch information
Rafael Mendonça França
committed
Oct 14, 2012
1 parent
0544c78
commit c4f9e10
Showing
8 changed files
with
43 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,4 +1,29 @@ | |||
require "rails/observers/version" | require "rails/observers/version" | ||
|
|
||
require "rails/observers/activerecord/observer" | module Rails | ||
require "rails/observers/action_controller/caching" | module Observes | ||
module Railtie < Rails::Railtie | |||
initializer "active_record.observer" do | |||
ActiveSupport.on_load(:active_record) do | |||
require "rails/observers/activerecord/active_record" | |||
end | |||
end | |||
|
|||
initializer "action_controller.caching.sweppers" do | |||
ActiveSupport.on_load(:action_controller) do | |||
require "rails/observers/action_controller/caching" | |||
end | |||
end | |||
|
|||
config.after_initialize do |app| | |||
ActiveSupport.on_load(:active_record) do | |||
ActiveRecord::Model.instantiate_observers | |||
|
|||
ActionDispatch::Reloader.to_prepare do | |||
ActiveRecord::Model.instantiate_observers | |||
end | |||
end | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,5 @@ | |||
require 'rails/observers/activerecord/model' | |||
|
|||
module ActiveRecord | module ActiveRecord | ||
autoload :Observer | autoload :Observer, 'rails/observers/activerecord/observer' | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,9 +1,15 @@ | |||
require 'rails/observers/active_model/active_model' | |||
|
|||
module ActiveRecord | module ActiveRecord | ||
module Model | module Model | ||
extend ActiveModel::Observing::ClassMethods | |||
|
|||
included do | included do | ||
extend ActiveModel::Observing::ClassMethods | |||
include ActiveModel::Observing | include ActiveModel::Observing | ||
end | end | ||
end | end | ||
|
|||
class Base | |||
extend ActiveModel::Observing::ClassMethods | |||
include ActiveModel::Observing | |||
end | |||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters