Sha256: bb3a1e30941a082a3ae53af7835b9f1c7c9520a5bc5d893261fbcadfcbfa360d

Contents?: true

Size: 1.27 KB

Versions: 19

Compression:

Stored size: 1.27 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
  # -->
  # Return the class refined by the receiver.
  #
  def refined_class: () -> Module
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rbs-3.3.2 core/refinement.rbs
rbs-3.3.1 core/refinement.rbs
rbs-3.3.0 core/refinement.rbs
rbs-3.3.0.pre.2 core/refinement.rbs
rbs-3.3.0.pre.1 core/refinement.rbs
rbs-3.2.2 core/refinement.rbs
rbs-3.2.1 core/refinement.rbs
rbs-3.2.0 core/refinement.rbs
rbs-3.2.0.pre.1 core/refinement.rbs
rbs-3.1.3 core/refinement.rbs
rbs-3.1.2 core/refinement.rbs
rbs-3.1.1 core/refinement.rbs
rbs-3.1.0 core/refinement.rbs
rbs-3.0.4 core/refinement.rbs
rbs-3.0.3 core/refinement.rbs
rbs-3.0.2 core/refinement.rbs
rbs-3.0.1 core/refinement.rbs
rbs-3.0.0 core/refinement.rbs
rbs-3.0.0.dev.3 core/refinement.rbs