use instance hooks provided by hooks instead of changing the gem’s source
This commit is contained in:
parent
247a152d39
commit
2ad91339bb
|
@ -33,6 +33,7 @@ module Middleman
|
||||||
|
|
||||||
# Uses callbacks
|
# Uses callbacks
|
||||||
include Hooks
|
include Hooks
|
||||||
|
include Hooks::InstanceHooks
|
||||||
|
|
||||||
# Before request hook
|
# Before request hook
|
||||||
define_hook :before
|
define_hook :before
|
||||||
|
@ -240,5 +241,11 @@ module Middleman
|
||||||
end
|
end
|
||||||
alias :inspect :to_s # Ruby 2.0 calls inspect for NoMethodError instead of to_s
|
alias :inspect :to_s # Ruby 2.0 calls inspect for NoMethodError instead of to_s
|
||||||
|
|
||||||
|
# Hooks clones _hooks from the class to the instance.
|
||||||
|
# https://github.com/apotonick/hooks/blob/master/lib/hooks/instance_hooks.rb#L10
|
||||||
|
# Middleman expects the same list of hooks for class and instance hooks:
|
||||||
|
def _hooks
|
||||||
|
self.class._hooks
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,7 +49,7 @@ class Middleman::CoreExtensions::Compass < ::Middleman::Extension
|
||||||
end
|
end
|
||||||
|
|
||||||
# Call hook
|
# Call hook
|
||||||
app.run_hook :compass_config, ::Compass.configuration
|
app.run_hook_for :compass_config, app, ::Compass.configuration
|
||||||
|
|
||||||
# Tell Tilt to use it as well (for inline sass blocks)
|
# Tell Tilt to use it as well (for inline sass blocks)
|
||||||
::Tilt.register 'sass', CompassSassTemplate
|
::Tilt.register 'sass', CompassSassTemplate
|
||||||
|
|
|
@ -77,11 +77,6 @@ module Hooks
|
||||||
end
|
end
|
||||||
|
|
||||||
def define_hook_writer(name)
|
def define_hook_writer(name)
|
||||||
self.send(:define_method, name.to_sym) do |&block|
|
|
||||||
if self.class.respond_to?(name)
|
|
||||||
self.class.send(name.to_sym, &block)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
instance_eval *hook_writer_args(name)
|
instance_eval *hook_writer_args(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue