Class: Mutineer::Subject

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

Overview

One discoverable method and its AST node.

Location, namespace context, and the live Prism::DefNode are kept together because mutators walk the def node directly.

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



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

def def_node
  @def_node
end

#fileObject

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



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

def file
  @file
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



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

def name
  @name
end

#namespaceObject

Returns the value of attribute namespace

Returns:

  • (Object)

    the current value of namespace



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

def namespace
  @namespace
end

#singletonObject

Returns the value of attribute singleton

Returns:

  • (Object)

    the current value of singleton



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

def singleton
  @singleton
end

Instance Method Details

#body_locPrism::Location?

Returns the body location for the subject, if any.

Returns:

  • (Prism::Location, nil)

    body location or nil for empty methods.



19
20
21
# File 'lib/mutineer/subject.rb', line 19

def body_loc
  def_node.body&.location
end

#qualified_nameString

Returns the fully-qualified subject name.

Returns:

  • (String)

    namespaced method name like Billing::Invoice#total.



12
13
14
# File 'lib/mutineer/subject.rb', line 12

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