Skip to content

Instantly share code, notes, and snippets.

@jimweirich
Created June 20, 2012 18:51
Show Gist options
  • Save jimweirich/2961532 to your computer and use it in GitHub Desktop.
Save jimweirich/2961532 to your computer and use it in GitHub Desktop.
Investigating "super unless allow" issues
# Demonstrating the the "super unless allow?(method)" line *might* cause
# problems, but only under weird circumstances involving the ancestors
# of the Draper::Base class. Since the ancestor list is pretty stable,
# this probably isn't an issue (note I had to include a module into
# Draper::Base to trigger the problem -- Yikes!).
#
# So, after analysis, "super unless allow?" isn't a practical problem.
#
# HOWEVER, it would be nice for the code to reflect that it isn't a
# problem without requiring extensive research.
context "in weird inheritance tree" do
PING_COUNTER = []
class NoPingDecorator < Decorator
denies :ping
end
module NastyAncestor
def method_missing(sym, *args, &block)
if sym == :ping
PING_COUNTER << :ping
else
super
end
end
end
class Draper::Base
include NastyAncestor
end
subject{ NoPingDecorator.new(source) }
it "is not called twice" do
PING_COUNTER.clear
subject.ping
PING_COUNTER.should == [:ping]
end
end
@steveklabnik
Copy link

Wow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment