Class: CodeWeb::MethodCache
- Inherits:
-
Object
- Object
- CodeWeb::MethodCache
- Defined in:
- lib/code_web/method_cache.rb
Instance Attribute Summary collapse
-
#arg_regex ⇒ Object
Returns the value of attribute arg_regex.
-
#method_calls ⇒ Object
Map<String,Array<MethodCall>>.
-
#method_regex ⇒ Object
only store the information on these methods.
Instance Method Summary collapse
- #<<(mc) ⇒ Object
- #detect?(mc) ⇒ Boolean
-
#initialize(method_regex = nil) ⇒ MethodCache
constructor
A new instance of MethodCache.
Constructor Details
#initialize(method_regex = nil) ⇒ MethodCache
Returns a new instance of MethodCache.
10 11 12 13 |
# File 'lib/code_web/method_cache.rb', line 10 def initialize(method_regex = nil) @method_calls=[] @method_regex = method_regex end |
Instance Attribute Details
#arg_regex ⇒ Object
Returns the value of attribute arg_regex.
8 9 10 |
# File 'lib/code_web/method_cache.rb', line 8 def arg_regex @arg_regex end |
#method_calls ⇒ Object
Map<String,Array<MethodCall>>
4 5 6 |
# File 'lib/code_web/method_cache.rb', line 4 def method_calls @method_calls end |
#method_regex ⇒ Object
only store the information on these methods
7 8 9 |
# File 'lib/code_web/method_cache.rb', line 7 def method_regex @method_regex end |
Instance Method Details
#<<(mc) ⇒ Object
15 16 17 |
# File 'lib/code_web/method_cache.rb', line 15 def <<(mc) @method_calls << mc if detect?(mc) end |
#detect?(mc) ⇒ Boolean
19 20 21 22 23 24 25 26 27 |
# File 'lib/code_web/method_cache.rb', line 19 def detect?(mc) (method_regex.nil? || mc.full_method_name =~ method_regex) && ( arg_regex.nil? || ( mc.hash_args? && mc.arg_keys.detect {|key| key =~ arg_regex } ) ) end |