Class: Inch::CodeObject::Proxy

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/inch/code_object/proxy.rb

Overview

CodeObject::Proxy object represent code objects in the analaysed codebase.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, object_lookup = nil) ⇒ 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



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

#inspectObject



53
54
55
# File 'lib/inch/code_object/proxy.rb', line 53

def inspect
  "#<#{self.class}: #{fullname}>"
end

#languageSymbol



39
40
41
# File 'lib/inch/code_object/proxy.rb', line 39

def language
  fail NotImplementedError
end

#marshal_dumpObject

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