Class: RubyDetective::SourceRepresentation::DataStore
- Inherits:
-
Object
- Object
- RubyDetective::SourceRepresentation::DataStore
- Includes:
- Singleton
- Defined in:
- lib/ruby_detective/source_representation/data_store.rb
Instance Attribute Summary collapse
-
#classes ⇒ Object
Returns the value of attribute classes.
-
#constants ⇒ Object
Returns the value of attribute constants.
Instance Method Summary collapse
- #clear! ⇒ Object
-
#initialize ⇒ DataStore
constructor
A new instance of DataStore.
- #inspect ⇒ Object
- #query ⇒ Object
- #register_class(name, namespace, inheritance_class_name:, file_path:, first_line:, last_line:) ⇒ Object
- #register_constant(name, namespace, file_path:, caller:, refers_to: nil) ⇒ Object
- #resolve_dependencies ⇒ Object
Constructor Details
#initialize ⇒ DataStore
Returns a new instance of DataStore.
12 13 14 15 |
# File 'lib/ruby_detective/source_representation/data_store.rb', line 12 def initialize @classes = [] @constants = [] end |
Instance Attribute Details
#classes ⇒ Object
Returns the value of attribute classes.
10 11 12 |
# File 'lib/ruby_detective/source_representation/data_store.rb', line 10 def classes @classes end |
#constants ⇒ Object
Returns the value of attribute constants.
10 11 12 |
# File 'lib/ruby_detective/source_representation/data_store.rb', line 10 def constants @constants end |
Instance Method Details
#clear! ⇒ Object
21 22 23 |
# File 'lib/ruby_detective/source_representation/data_store.rb', line 21 def clear! initialize end |
#inspect ⇒ Object
25 26 27 |
# File 'lib/ruby_detective/source_representation/data_store.rb', line 25 def inspect "#<RubyDetective::SourceRepresentation::DataStore>" end |
#query ⇒ Object
17 18 19 |
# File 'lib/ruby_detective/source_representation/data_store.rb', line 17 def query Query.new end |
#register_class(name, namespace, inheritance_class_name:, file_path:, first_line:, last_line:) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ruby_detective/source_representation/data_store.rb', line 33 def register_class(name, namespace, inheritance_class_name:, file_path:, first_line:, last_line:) klass = Entities::Klass.new( name, namespace, inheritance_class_name: inheritance_class_name, file_path: file_path, first_line: first_line, last_line: last_line ) existing_class = query.classes(where: { path: klass.path }).first if existing_class existing_class.merge(klass) existing_class else @classes << klass klass end end |
#register_constant(name, namespace, file_path:, caller:, refers_to: nil) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ruby_detective/source_representation/data_store.rb', line 54 def register_constant(name, namespace, file_path:, caller:, refers_to: nil) constant = Entities::Constant.new( name, namespace, caller: caller, refers_to: refers_to, file_path: file_path ) @constants << constant constant end |
#resolve_dependencies ⇒ Object
29 30 31 |
# File 'lib/ruby_detective/source_representation/data_store.rb', line 29 def resolve_dependencies DependencyResolver.resolve_and_populate_store end |