Class: Inch::CodeObject::Proxy
- Inherits:
-
Object
- Object
- Inch::CodeObject::Proxy
- Extended by:
- Forwardable
- Defined in:
- lib/inch/code_object/proxy.rb
Overview
CodeObject::Proxy object represent code objects in the analaysed codebase.
Direct Known Subclasses
Language::Elixir::CodeObject::Base, Language::JavaScript::CodeObject::Base, Language::Ruby::CodeObject::Base
Instance Attribute Summary collapse
-
#object_lookup ⇒ #find
An object that responds to #find to look up objects by their full name.
Class Method Summary collapse
-
.for(language, code_object, object_lookup) ⇒ CodeObject::Proxy
Returns a Proxy object for the given
code_object
.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Returns the attribute for the given
key
. -
#initialize(attributes = {}, object_lookup = nil) ⇒ Proxy
constructor
A new instance of Proxy.
- #inspect ⇒ Object
-
#language ⇒ Symbol
The programming language of the code object.
-
#marshal_dump ⇒ Object
Used to persist the code object.
-
#marshal_load(attributes) ⇒ Object
Used to load a persisted code object.
Constructor Details
#initialize(attributes = {}, object_lookup = nil) ⇒ Proxy
Returns a new instance of Proxy.
26 27 28 29 |
# File 'lib/inch/code_object/proxy.rb', line 26 def initialize(attributes = {}, object_lookup = nil) @attributes = attributes @object_lookup = object_lookup end |
Instance Attribute Details
#object_lookup ⇒ #find
Returns an object that responds to #find to look up objects by their full name.
23 24 25 |
# File 'lib/inch/code_object/proxy.rb', line 23 def object_lookup @object_lookup end |
Class Method Details
.for(language, code_object, object_lookup) ⇒ CodeObject::Proxy
Returns a Proxy object for the given code_object
13 14 15 16 |
# File 'lib/inch/code_object/proxy.rb', line 13 def self.for(language, code_object, object_lookup) attributes = Converter.to_hash(code_object) class_for(language, code_object).new(attributes, object_lookup) end |
Instance Method Details
#[](key) ⇒ Object
Returns the attribute for the given key
34 35 36 |
# File 'lib/inch/code_object/proxy.rb', line 34 def [](key) @attributes[key] end |
#inspect ⇒ Object
53 54 55 |
# File 'lib/inch/code_object/proxy.rb', line 53 def inspect "#<#{self.class}: #{fullname}>" end |
#language ⇒ Symbol
Returns the programming language of the code object.
39 40 41 |
# File 'lib/inch/code_object/proxy.rb', line 39 def language fail NotImplementedError end |
#marshal_dump ⇒ Object
Used to persist the code object
44 45 46 |
# File 'lib/inch/code_object/proxy.rb', line 44 def marshal_dump @attributes end |
#marshal_load(attributes) ⇒ Object
Used to load a persisted code object
49 50 51 |
# File 'lib/inch/code_object/proxy.rb', line 49 def marshal_load(attributes) @attributes = attributes end |