lib/deface/action_view_extensions.rb in deface-0.8.0 vs lib/deface/action_view_extensions.rb in deface-0.9.0

- old
+ new

@@ -21,26 +21,36 @@ # refresh view to get source again if # view needs to be recompiled # def render(view, locals, buffer=nil, &block) - if @compiled && !view.respond_to?(method_name) + + if view.is_a?(ActionView::CompiledTemplates) + mod = ActionView::CompiledTemplates + else + mod = view.singleton_class + end + + if @compiled && !mod.instance_methods.map(&:to_s).include?(method_name) @compiled = false @source = refresh(view).source end render_without_deface(view, locals, buffer, &block) end + protected - alias_method :method_name_without_deface, :method_name + alias_method :method_name_without_deface, :method_name - # inject deface hash into compiled view method name - # used to determine if recompilation is needed - # - def method_name - deface_hash = Deface::Override.digest(:virtual_path => @virtual_path) - "_#{deface_hash}_#{method_name_without_deface}" - end + # inject deface hash into compiled view method name + # used to determine if recompilation is needed + # + def method_name + deface_hash = Deface::Override.digest(:virtual_path => @virtual_path) + + #we digest the whole method name as if it gets too long there's problems + "_#{Digest::MD5.new.update("#{deface_hash}_#{method_name_without_deface}").hexdigest}" + end end #fix for Rails 3.1 not setting virutal_path anymore (BOO!) if defined?(ActionView::Resolver::Path) ActionView::Resolver::Path.class_eval { alias_method :virtual, :to_s }