I’m monkey patching the Guardian class in Babble here:
class ::Guardian
module CanSeeTopic
def can_see_topic?(topic)
super || some_other_condition
end
end
prepend CanSeeTopic
end
Module#prepend is a little opaque, but in short it allows you to invoke the ‘original’ function of the class with super. Then you can add additional checks to the function to suit your needs.
If you don’t care about what the original functionality is, you can also simply wipe the original implementation like so:
class ::Guardian
def can_see_topic?(topic)
false # no topics for anyone! 😈
end
end
Note that this is a little bit riskier because the original implementation may change without you knowing it.