Class: Yoda::Store::Objects::Patch::ParentModifier
- Inherits:
-
Object
- Object
- Yoda::Store::Objects::Patch::ParentModifier
- Defined in:
- lib/yoda/store/objects/patch.rb
Instance Attribute Summary collapse
-
#patch ⇒ Object
readonly
Returns the value of attribute patch.
Instance Method Summary collapse
- #add_address_to_parent(code_object) ⇒ void
- #create_parent_module(code_object) ⇒ Object
-
#initialize(patch) ⇒ ParentModifier
constructor
A new instance of ParentModifier.
Constructor Details
#initialize(patch) ⇒ ParentModifier
Returns a new instance of ParentModifier.
58 59 60 |
# File 'lib/yoda/store/objects/patch.rb', line 58 def initialize(patch) @patch = patch end |
Instance Attribute Details
#patch ⇒ Object (readonly)
Returns the value of attribute patch.
55 56 57 |
# File 'lib/yoda/store/objects/patch.rb', line 55 def patch @patch end |
Instance Method Details
#add_address_to_parent(code_object) ⇒ void
This method returns an undefined value.
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/yoda/store/objects/patch.rb', line 64 def add_address_to_parent(code_object) parent_module = patch.find(code_object.parent_address) || create_parent_module(code_object) return unless parent_module.namespace? patch.register(parent_module) if !patch.has_key?(parent_module.address) && parent_module.address != code_object.address case code_object.kind when :method parent_module.instance_method_addresses.push(code_object.address) unless parent_module.instance_method_addresses.include?(code_object.address) when :class, :module, :value parent_module.constant_addresses.push(code_object.address) unless parent_module.constant_addresses.include?(code_object.address) end end |
#create_parent_module(code_object) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/yoda/store/objects/patch.rb', line 77 def create_parent_module(code_object) if code_object.address == code_object.parent_address code_object elsif MetaClassObject.(code_object.parent_address) MetaClassObject.new(path: MetaClassObject.path_of(code_object.parent_address)) else ModuleObject.new(path: code_object.parent_address) end end |