Class: Mutineer::Subject
- Inherits:
-
Struct
- Object
- Struct
- Mutineer::Subject
- 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. namespace names the owner
(module ::X inside Outer owns into X); lexical is the class/module
chain as written (["Outer", "::X"]), which the redefine strategy needs to
rebuild the same Module.nesting as a whole-file reload (#145).
Instance Attribute Summary collapse
-
#def_node ⇒ Object
Returns the value of attribute def_node.
-
#file ⇒ Object
Returns the value of attribute file.
-
#lexical ⇒ Object
Returns the value of attribute lexical.
-
#name ⇒ Object
Returns the value of attribute name.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#singleton ⇒ Object
Returns the value of attribute singleton.
Instance Method Summary collapse
-
#body_loc ⇒ Prism::Location?
Returns the body location for the subject, if any.
-
#lexical_namespace ⇒ Array<String>
Class/module chain as written in the source, for textual wrappers.
-
#qualified_name ⇒ String
Returns the fully-qualified subject name.
Instance Attribute Details
#def_node ⇒ Object
Returns the value of attribute def_node
11 12 13 |
# File 'lib/mutineer/subject.rb', line 11 def def_node @def_node end |
#file ⇒ Object
Returns the value of attribute file
11 12 13 |
# File 'lib/mutineer/subject.rb', line 11 def file @file end |
#lexical ⇒ Object
Returns the value of attribute lexical
11 12 13 |
# File 'lib/mutineer/subject.rb', line 11 def lexical @lexical end |
#name ⇒ Object
Returns the value of attribute name
11 12 13 |
# File 'lib/mutineer/subject.rb', line 11 def name @name end |
#namespace ⇒ Object
Returns the value of attribute namespace
11 12 13 |
# File 'lib/mutineer/subject.rb', line 11 def namespace @namespace end |
#singleton ⇒ Object
Returns the value of attribute singleton
11 12 13 |
# File 'lib/mutineer/subject.rb', line 11 def singleton @singleton end |
Instance Method Details
#body_loc ⇒ Prism::Location?
Returns the body location for the subject, if any.
30 31 32 |
# File 'lib/mutineer/subject.rb', line 30 def body_loc def_node.body&.location end |
#lexical_namespace ⇒ Array<String>
Class/module chain as written in the source, for textual wrappers. Falls
back to namespace for subjects built without one.
23 24 25 |
# File 'lib/mutineer/subject.rb', line 23 def lexical_namespace lexical || namespace end |
#qualified_name ⇒ String
Returns the fully-qualified subject name.
15 16 17 |
# File 'lib/mutineer/subject.rb', line 15 def qualified_name namespace.join("::") + (singleton ? "." : "#") + name.to_s end |