Sha256: 34ece2615a0dc8626cdc67ecf1b5fe0eeb4f1d6909ef724509c469c5dac83508

Contents?: true

Size: 1.58 KB

Versions: 11

Compression:

Stored size: 1.58 KB

Contents

# <!-- rdoc-file=class.c -->
# Refinement is a class of the `self` (current context) inside `refine`
# statement. It allows to import methods from other modules, see
# #import_methods.
#
class Refinement < Module
  private

  # <!--
  #   rdoc-file=class.c
  #   - import_methods(module, ...)    -> self
  # -->
  # Imports methods from modules. Unlike Module#include, Refinement#import_methods
  # copies methods and adds them into the refinement, so the refinement is
  # activated in the imported methods.
  #
  # Note that due to method copying, only methods defined in Ruby code can be
  # imported.
  #
  #     module StrUtils
  #       def indent(level)
  #         ' ' * level + self
  #       end
  #     end
  #
  #     module M
  #       refine String do
  #         import_methods StrUtils
  #       end
  #     end
  #
  #     using M
  #     "foo".indent(3)
  #     #=> "   foo"
  #
  #     module M
  #       refine String do
  #         import_methods Enumerable
  #         # Can't import method which is not defined with Ruby code: Enumerable#drop
  #       end
  #     end
  #
  def import_methods: (*Module) -> self

  # <!--
  #   rdoc-file=eval.c
  #   - refined_class    -> class
  # -->
  # Deprecated; prefer #target.
  #
  # Return the class refined by the receiver.
  #
  def refined_class: () -> Module

  # <!--
  #   rdoc-file=eval.c
  #   - target    -> class_or_module
  # -->
  # Return the class or module refined by the receiver.
  #
  #     module M
  #       refine String do
  #       end
  #     end
  #
  #     M.refinements[0].target # => String
  #
  def target: () -> Module
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rbs-3.5.3 core/refinement.rbs
rbs-3.5.2 core/refinement.rbs
rbs-3.5.1 core/refinement.rbs
rbs-3.5.1.pre.1 core/refinement.rbs
rbs-3.5.0 core/refinement.rbs
rbs-3.5.0.pre.2 core/refinement.rbs
rbs-3.5.0.pre.1 core/refinement.rbs
rbs-3.4.4 core/refinement.rbs
rbs-3.4.3 core/refinement.rbs
rbs-3.4.2 core/refinement.rbs
rbs-3.4.1 core/refinement.rbs