Class: Safemode::Blankslate
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
- .allow(*names) ⇒ Object
- .allowed?(name) ⇒ Boolean
- .allowed_methods ⇒ Object
- .inherited(subclass) ⇒ Object
- .init_allowed_methods(allowed_methods) ⇒ Object
-
.method_added(name) ⇒ Object
ActiveSupport needs this.
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
29 30 31 |
# File 'lib/safemode/blankslate.rb', line 29 def allowed?(name) allowed_methods.include? name.to_s end |
.allowed_methods ⇒ Object
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 |