Class: Delfos::Patching::ModuleDefiner
- Inherits:
- 
      Object
      
        - Object
- Delfos::Patching::ModuleDefiner
 
- Defined in:
- lib/delfos/patching/module_defining_methods.rb
Instance Attribute Summary collapse
- 
  
    
      #class_method  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute class_method. 
- 
  
    
      #klass  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute klass. 
- 
  
    
      #method_name  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute method_name. 
Instance Method Summary collapse
- 
  
    
      #initialize(klass, method_name, class_method)  ⇒ ModuleDefiner 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of ModuleDefiner. 
- #perform(&block) ⇒ Object
Constructor Details
#initialize(klass, method_name, class_method) ⇒ ModuleDefiner
Returns a new instance of ModuleDefiner.
| 26 27 28 | # File 'lib/delfos/patching/module_defining_methods.rb', line 26 def initialize(klass, method_name, class_method) @klass, @method_name, @class_method = klass, method_name, class_method end | 
Instance Attribute Details
#class_method ⇒ Object (readonly)
Returns the value of attribute class_method.
| 24 25 26 | # File 'lib/delfos/patching/module_defining_methods.rb', line 24 def class_method @class_method end | 
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
| 24 25 26 | # File 'lib/delfos/patching/module_defining_methods.rb', line 24 def klass @klass end | 
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
| 24 25 26 | # File 'lib/delfos/patching/module_defining_methods.rb', line 24 def method_name @method_name end | 
Instance Method Details
#perform(&block) ⇒ Object
| 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | # File 'lib/delfos/patching/module_defining_methods.rb', line 30 def perform(&block) safe_method_name = safe_method_name() safe_class_name = safe_class_name() module_type = class_method ? "ClassMethodLogging" : "InstanceMethodLogging" find_or_create = method(:find_or_create) m = nil Patching.const_get(module_type).instance_eval do namespace = find_or_create.call(self, safe_class_name) m = find_or_create.call(namespace, safe_method_name) m.class_eval(&block) if block_given? m end end |