Class: Mutineer::Subject

Inherits:
Struct
  • Object
show all
Defined in:
lib/mutineer/subject.rb

Overview

One discoverable method: its location, namespace context, and the live Prism::DefNode mutators walk. Struct (not Data) because def_node is a live AST node — value-equality would be hollow, so we don't promise it.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#def_nodeObject

Returns the value of attribute def_node

Returns:

  • (Object)

    the current value of def_node



7
8
9
# File 'lib/mutineer/subject.rb', line 7

def def_node
  @def_node
end

#fileObject

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



7
8
9
# File 'lib/mutineer/subject.rb', line 7

def file
  @file
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



7
8
9
# File 'lib/mutineer/subject.rb', line 7

def name
  @name
end

#namespaceObject

Returns the value of attribute namespace

Returns:

  • (Object)

    the current value of namespace



7
8
9
# File 'lib/mutineer/subject.rb', line 7

def namespace
  @namespace
end

#singletonObject

Returns the value of attribute singleton

Returns:

  • (Object)

    the current value of singleton



7
8
9
# File 'lib/mutineer/subject.rb', line 7

def singleton
  @singleton
end

Instance Method Details

#body_locObject

nil for empty methods (def empty; end).



15
16
17
# File 'lib/mutineer/subject.rb', line 15

def body_loc
  def_node.body&.location
end

#qualified_nameObject

e.g. "Billing::Invoice#total", "Billing::Invoice.build".

Top-level (empty namespace) -> "#name" (no

prefix).



10
11
12
# File 'lib/mutineer/subject.rb', line 10

def qualified_name
  namespace.join("::") + (singleton ? "." : "#") + name.to_s
end