Class: Safemode::Blankslate

Inherits:
Object show all
Defined in:
lib/safemode/blankslate.rb

Direct Known Subclasses

Jail, Scope

Constant Summary collapse

@@allow_instance_methods =
['class', 'methods', 'respond_to?', 'respond_to_missing?', 'to_s', 'instance_variable_get']
@@allow_class_methods =

< needed in Rails Object#subclasses_of

['methods', 'new', 'name', '<', 'ancestors', '==']

Class Method Summary collapse

Class Method Details

.allow(*names) ⇒ Object



24
25
26
27
# File 'lib/safemode/blankslate.rb', line 24

def allow(*names)
  @allowed_methods = allowed_methods + names.map{|name| name.to_s}
  @allowed_methods.uniq!
end

.allowed?(name) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/safemode/blankslate.rb', line 29

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

.allowed_methodsObject



20
21
22
# File 'lib/safemode/blankslate.rb', line 20

def allowed_methods
  @allowed_methods ||= []
end

.inherited(subclass) ⇒ Object



12
13
14
# File 'lib/safemode/blankslate.rb', line 12

def inherited(subclass)
  subclass.init_allowed_methods(@allowed_methods)
end

.init_allowed_methods(allowed_methods) ⇒ Object



16
17
18
# File 'lib/safemode/blankslate.rb', line 16

def init_allowed_methods(allowed_methods)
  @allowed_methods = allowed_methods
end

.method_added(name) ⇒ Object

ActiveSupport needs this



10
# File 'lib/safemode/blankslate.rb', line 10

def method_added(name) end