Class: ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Commands::GeneratePrintableMethod

Inherits:
Support::Command
  • Object
show all
Defined in:
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/commands/generate_printable_method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(object:, method:) ⇒ void

Parameters:

  • object (Object)

    Can by any type.

  • method (Symbol, String)


32
33
34
35
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/commands/generate_printable_method.rb', line 32

def initialize(object:, method:)
  @object = object
  @method = method
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



25
26
27
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/commands/generate_printable_method.rb', line 25

def method
  @method
end

#objectObject (readonly)

Returns the value of attribute object.



19
20
21
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/commands/generate_printable_method.rb', line 19

def object
  @object
end

Instance Method Details

#callObject



37
38
39
40
41
42
43
44
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/commands/generate_printable_method.rb', line 37

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