Permalink
Browse files

Added 'refinery.before_inclusion' and 'refinery.after_inclusion' (ren…

…amed from 'refinery.on_attach') to hook into Refinery or Rails before or after Refinery's inclusion into Rails (fires inside the Refinery::Application.refinery! method).
  • Loading branch information...
parndt committed Mar 28, 2011
1 parent 02c20a6 commit eedb9f2078f9b717964c81f43248d8a0416c7768
Showing with 23 additions and 6 deletions.
  1. +5 −0 changelog.md
  2. +5 −1 core/lib/refinery/application.rb
  3. +12 −4 core/lib/refinery/configuration.rb
  4. +1 −1 pages/lib/refinerycms-pages.rb
View
@@ -1,3 +1,8 @@
+## 0.9.9.14 [unreleased]
+
+* Added `refinery.before_inclusion` for running extra functionality just before Refinery attaches to Rails. [Philip Arndt](https://github.com/parndt)
+* Renamed `refinery.after_inclusion` to `refinery.after_inclusion` to match `refinery.before_inclusion`. [Philip Arndt](https://github.com/parndt)
+
## 0.9.9.13 [28 March 2011]
* Forcing password reset when migrating from older versions of Devise (sigh). [Philip Arndt](https://github.com/parndt)
@@ -6,6 +6,10 @@ module Application
class << self
def refinery!
+ ::Refinery.config.before_inclusion_procs.each do |proc|
+ proc.call if proc.respond_to?(:call)
+ end
+
::ApplicationHelper.send :include, ::Refinery::ApplicationHelper
[::ApplicationController, ::Admin::BaseController].each do |c|
@@ -15,7 +19,7 @@ def refinery!
::Admin::BaseController.send :include, ::Refinery::Admin::BaseController
- ::Refinery.config.on_attach_procs.each do |proc|
+ ::Refinery.config.after_inclusion_procs.each do |proc|
proc.call if proc.respond_to?(:call)
end
end
@@ -1,12 +1,20 @@
module Refinery
class Configuration
- def on_attach_procs
- @@on_attach_procs ||= []
+ def after_inclusion_procs
+ @@after_inclusion_procs ||= []
end
- def on_attach(&blk)
- on_attach_procs << blk if blk
+ def after_inclusion(&blk)
+ after_inclusion_procs << blk if blk
+ end
+
+ def before_inclusion_procs
+ @@before_inclusion_procs ||= []
+ end
+
+ def before_inclusion(&blk)
+ before_inclusion_procs << blk if blk
end
end
@@ -23,7 +23,7 @@ class Engine < ::Rails::Engine
require File.expand_path('../pages/tabs', __FILE__)
end
- refinery.on_attach do
+ refinery.after_inclusion do
::ApplicationController.send :include, ::Refinery::Pages::InstanceMethods
end

0 comments on commit eedb9f2

Please sign in to comment.