Class: Benelux::MethodCounter
- Inherits:
-
MethodPacker
- Object
- MethodPacker
- Benelux::MethodCounter
- Defined in:
- lib/benelux/packer.rb
Instance Attribute Summary collapse
-
#counter ⇒ Object
readonly
Returns the value of attribute counter.
Attributes inherited from MethodPacker
#aliaz, #blk, #klass, #meth, #methorig
Attributes included from Selectable::Object
Instance Method Summary collapse
- #determine_count(args, ret) ⇒ Object
- #generate_packed_method(callblock = false) ⇒ Object
- #install_method ⇒ Object
Methods inherited from MethodPacker
class_method_defined?, #initialize, #instance_exec, method_defined?, #run_block
Methods included from Selectable::Object
#add_tags, #add_tags_quick, #init_tags!, #remove_tags, #tag_values
Constructor Details
This class inherits a constructor from Benelux::MethodPacker
Instance Attribute Details
#counter ⇒ Object (readonly)
Returns the value of attribute counter.
141 142 143 |
# File 'lib/benelux/packer.rb', line 141 def counter @counter end |
Instance Method Details
#determine_count(args, ret) ⇒ Object
161 162 163 164 |
# File 'lib/benelux/packer.rb', line 161 def determine_count(args,ret) return 1 if @blk.nil? self.instance_exec args, ret, &blk end |
#generate_packed_method(callblock = false) ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/benelux/packer.rb', line 146 def generate_packed_method(callblock=false) %Q{ def #{@meth}(*args, &block) Benelux.current_track :global unless Benelux.known_thread? # Get a reference to this MethodCounter instance cmd = Benelux.packed_method #{@klass}, :#{@meth} ret = #{@methorig}(*args, &block) count = cmd.determine_count(args, ret) #Benelux.ld "COUNT(:#{@meth}): \#{count}" Benelux.current_track.timeline.add_count :'#{@meth}', count ret end } end |
#install_method ⇒ Object
142 143 144 |
# File 'lib/benelux/packer.rb', line 142 def install_method @klass.module_eval generate_packed_method, __FILE__, 122 end |