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)


27
28
29
30
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/commands/generate_printable_method.rb', line 27

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

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



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

def method
  @method
end

#objectObject (readonly)

Returns the value of attribute object.



14
15
16
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/commands/generate_printable_method.rb', line 14

def object
  @object
end

Instance Method Details

#callObject



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

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