Class: Delorean::Ruby::Whitelists::Base
- Inherits:
-
Object
- Object
- Delorean::Ruby::Whitelists::Base
- Defined in:
- lib/delorean/ruby/whitelists/base.rb
Instance Attribute Summary collapse
-
#class_method_matchers ⇒ Object
readonly
Returns the value of attribute class_method_matchers.
-
#matchers ⇒ Object
readonly
Returns the value of attribute matchers.
Instance Method Summary collapse
- #add_class_method(method_name, match_to: nil, &block) ⇒ Object
- #add_method(method_name, match_to: nil, &block) ⇒ Object
- #class_method_matcher(method_name:) ⇒ Object
- #matcher(method_name:) ⇒ Object
Instance Attribute Details
#class_method_matchers ⇒ Object (readonly)
Returns the value of attribute class_method_matchers.
11 12 13 |
# File 'lib/delorean/ruby/whitelists/base.rb', line 11 def class_method_matchers @class_method_matchers end |
#matchers ⇒ Object (readonly)
Returns the value of attribute matchers.
10 11 12 |
# File 'lib/delorean/ruby/whitelists/base.rb', line 10 def matchers @matchers end |
Instance Method Details
#add_class_method(method_name, match_to: nil, &block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/delorean/ruby/whitelists/base.rb', line 32 def add_class_method(method_name, match_to: nil, &block) return method_name_error unless method_name.is_a?(Symbol) return block_and_match_error if !match_to.nil? && block_given? unless match_to.nil? return add_class_matched_method( method_name: method_name, match_to: match_to ) end matcher = class_method_matchers[method_name.to_sym] return matcher.extend_matcher(&block) if matcher class_method_matchers[method_name.to_sym] = method_matcher_class.new( method_name: method_name, &block ) end |
#add_method(method_name, match_to: nil, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/delorean/ruby/whitelists/base.rb', line 13 def add_method(method_name, match_to: nil, &block) return method_name_error unless method_name.is_a?(Symbol) return block_and_match_error if !match_to.nil? && block_given? unless match_to.nil? return add_matched_method( method_name: method_name, match_to: match_to ) end matcher = matchers[method_name.to_sym] return matcher.extend_matcher(&block) if matcher matchers[method_name.to_sym] = method_matcher_class.new( method_name: method_name, &block ) end |
#class_method_matcher(method_name:) ⇒ Object
55 56 57 |
# File 'lib/delorean/ruby/whitelists/base.rb', line 55 def class_method_matcher(method_name:) class_method_matchers[method_name.to_sym] end |
#matcher(method_name:) ⇒ Object
51 52 53 |
# File 'lib/delorean/ruby/whitelists/base.rb', line 51 def matcher(method_name:) matchers[method_name.to_sym] end |