Skip to content

Commit

Permalink
moved jail-methods out of blankslate
Browse files Browse the repository at this point in the history
  • Loading branch information
kronn committed Apr 23, 2010
1 parent 022c81d commit c076d4f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
21 changes: 0 additions & 21 deletions plugins/adva_safemode/lib/safemode/blankslate.rb
Expand Up @@ -9,27 +9,6 @@ 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{|name| name.to_s}
@allowed_methods.uniq!
end

def allowed?(name)
allowed_methods.include? name.to_s
end
end
end
end
25 changes: 25 additions & 0 deletions plugins/adva_safemode/lib/safemode/jail.rb
@@ -1,5 +1,30 @@
module Safemode
class Jail < Blankslate
class << self
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{|name| name.to_s}
@allowed_methods.uniq!
end

def allowed?(name)
allowed_methods.include? name.to_s
end
end

def initialize(source = nil)
@source = source
end
Expand Down

0 comments on commit c076d4f

Please sign in to comment.