Sha256: 1c1be640166f54e47dd512c17933e643076a4c672dc2c3ed9e5b720b310ab780

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module RSpec
    module PrimitiveMatchers
      module Classes
        class DelegateTo
          module Commands
            class GeneratePrintableMethod < Support::Command
              ##
              # @!attribute [r] object
              #   @return [Object] Can be any type.
              #
              attr_reader :object

              ##
              # @!attribute [r] method
              #   @return [Symbol, String]
              #
              attr_reader :method

              ##
              # @param object [Object] Can by any type.
              # @param method [Symbol, String]
              # @return [void]
              #
              def initialize(object:, method:)
                @object = object
                @method = method
              end

              def call
                case Utils::Object.resolve_type(object)
                when "class", "module"
                  "#{object}.#{method}"
                when "instance"
                  "#{object.class}##{method}"
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
convenient_service-0.19.1 lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/commands/generate_printable_method.rb
convenient_service-0.19.0 lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/commands/generate_printable_method.rb
convenient_service-0.18.0 lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/commands/generate_printable_method.rb