code: def _create_refinement_wrapper(transformation, baseattr, base, target_attrname):
          
          # first step: extract the original
          special_refinement_type=None
          instance_refinement = _is_class_instance(base)
  
          if instance_refinement:
              dictelem = base.__class__.__dict__.get(target_attrname, None)
          else:
              dictelem = base.__dict__.get(target_attrname, None)
  
          if isinstance(dictelem, staticmethod):
              special_refinement_type = 'staticmethod'
              original = _extract_staticmethod(dictelem)
          elif isinstance(dictelem, classmethod):
              special_refinement_type = 'classmethod'
              original = _extract_classmethod(dictelem)
          else:
              if instance_refinement:
                  # methods need a delegator
                  original = _delegate(baseattr)
                  # TODO: evaluate this:
                  # original = base.__class__.__dict__[target_attrname]
              else:
                  # default handling
                  original = baseattr
  
          # step two: call the refinement passing it the original
          # the result is the wrapper
          wrapper = transformation(original)
  
          # rescue docstring
          if not wrapper.__doc__:
              wrapper.__doc__ = baseattr.__doc__
  
          # step three: make wrapper ready for injection
          if special_refinement_type == 'staticmethod':
              wrapper = staticmethod(wrapper)
          elif special_refinement_type == 'classmethod':
              wrapper = classmethod(wrapper)
  
          if instance_refinement:
              wrapper = wrapper.__get__(base, base.__class__)
  
          return wrapper
docs: applies refinement ``transformation`` to ``baseattr`` attribute of ``base``.
          ``baseattr`` can be any type of callable (function, method, functor)
          this method handles the differences.
          docstrings are also rescued from the original if the refinement
          has no docstring set.