# remaining class methods: # allow, allowed?, allowed_methods, inherited, init_allowed_methods, inspect, # method_added, methods, name, new # # remaining instance methods: # class, inspect, methods, to_s module Haml module Safemode class Blankslate @@allow_instance_methods = ['class', 'inspect', 'methods', 'to_s'] @@allow_class_methods = ['methods', 'new', 'name', 'inspect'] silently { undef_methods(*instance_methods - @@allow_instance_methods) } class << self silently { undef_methods(*instance_methods - @@allow_class_methods) } def method_added(name) end # ActiveSupport needs this def inherited(subclass) subclass.init_allowed_methods(@allowed_methods) end def init_allowed_methods(allowed_methods) @allowed_methods = allowed_methods end def allowed_methods @allowed_methods ||= [] end def allow(*names) @allowed_methods = allowed_methods + names.map(&:to_s) end def allowed?(name) allowed_methods.include? name.to_s end end end end end