Module: Solid::MethodWhitelist
- Extended by:
- MethodWhitelist
- Included in:
- MethodWhitelist, Parser::MethodCall
- Defined in:
- lib/solid/method_whitelist.rb
Constant Summary collapse
- METHODS_WHITELIST =
{}
- METHODS_BLACKLIST =
{}
Class Method Summary collapse
Class Method Details
.allow(rules) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/solid/method_whitelist.rb', line 10 def allow(rules) rules.each do |owner, method_names| list = METHODS_WHITELIST[owner] ||= Set.new [method_names].flatten.each do |method_name| list.add(method_name.to_sym) end end self end |
.deny(rules) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/solid/method_whitelist.rb', line 20 def deny(rules) rules.each do |owner, method_names| list = METHODS_BLACKLIST[owner] ||= Set.new [method_names].flatten.each do |method_name| list.add(method_name.to_sym) end end self end |
.safely_respond_to?(object, method) ⇒ Boolean
32 33 34 35 36 |
# File 'lib/solid/method_whitelist.rb', line 32 def safely_respond_to?(object, method) return false unless object.respond_to?(method, false) method = object.method(method) (!inherited?(object, method) || whitelisted?(method)) && !blacklisted?(method) end |