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_class_method(*names) ⇒ Object
- .allow_instance_method(*names) ⇒ Object (also: allow)
- .allowed_class_method?(name) ⇒ Boolean
- .allowed_class_methods ⇒ Object
- .allowed_instance_method?(name) ⇒ Boolean (also: allowed?)
- .allowed_instance_methods ⇒ Object (also: allowed_methods)
- .inherited(subclass) ⇒ Object
- .init_allowed_methods(allowed_instance_methods, allowed_class_methods) ⇒ Object
-
.method_added(name) ⇒ Object
ActiveSupport needs this.
Class Method Details
.allow_class_method(*names) ⇒ Object
42 43 44 45 |
# File 'lib/safemode/blankslate.rb', line 42 def allow_class_method(*names) @allowed_class_methods = allowed_class_methods + names.map{|name| name.to_s} @allowed_class_methods.uniq! end |
.allow_instance_method(*names) ⇒ Object Also known as: allow
36 37 38 39 |
# File 'lib/safemode/blankslate.rb', line 36 def allow_instance_method(*names) @allowed_instance_methods = allowed_instance_methods + names.map{|name| name.to_s} @allowed_instance_methods.uniq! end |
.allowed_class_method?(name) ⇒ Boolean
52 53 54 |
# File 'lib/safemode/blankslate.rb', line 52 def allowed_class_method?(name) allowed_class_methods.include? name.to_s end |
.allowed_class_methods ⇒ Object
32 33 34 |
# File 'lib/safemode/blankslate.rb', line 32 def allowed_class_methods @allowed_class_methods ||= [] end |
.allowed_instance_method?(name) ⇒ Boolean Also known as: allowed?
47 48 49 |
# File 'lib/safemode/blankslate.rb', line 47 def allowed_instance_method?(name) allowed_instance_methods.include? name.to_s end |
.allowed_instance_methods ⇒ Object Also known as: allowed_methods
27 28 29 |
# File 'lib/safemode/blankslate.rb', line 27 def allowed_instance_methods @allowed_instance_methods ||= [] end |
.inherited(subclass) ⇒ Object
18 19 20 |
# File 'lib/safemode/blankslate.rb', line 18 def inherited(subclass) subclass.init_allowed_methods(@allowed_instance_methods, @allowed_class_methods) end |
.init_allowed_methods(allowed_instance_methods, allowed_class_methods) ⇒ Object
22 23 24 25 |
# File 'lib/safemode/blankslate.rb', line 22 def init_allowed_methods(allowed_instance_methods, allowed_class_methods) @allowed_instance_methods = allowed_instance_methods @allowed_class_methods = allowed_class_methods end |
.method_added(name) ⇒ Object
ActiveSupport needs this
16 |
# File 'lib/safemode/blankslate.rb', line 16 def method_added(name) end |