Class: RubyDetective::SourceRepresentation::Query
- Inherits:
-
Object
- Object
- RubyDetective::SourceRepresentation::Query
- Defined in:
- lib/ruby_detective/source_representation/query.rb
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #classes(where: {}) ⇒ Object
- #constants(where: {}) ⇒ Object
-
#initialize ⇒ Query
constructor
A new instance of Query.
Constructor Details
#initialize ⇒ Query
Returns a new instance of Query.
6 7 8 |
# File 'lib/ruby_detective/source_representation/query.rb', line 6 def initialize @store = DataStore.instance end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
4 5 6 |
# File 'lib/ruby_detective/source_representation/query.rb', line 4 def store @store end |
Instance Method Details
#classes(where: {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ruby_detective/source_representation/query.rb', line 23 def classes(where: {}) classes = store.classes case when where.key?(:path) classes.select { |c| c.path == where[:path] } else classes end end |
#constants(where: {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ruby_detective/source_representation/query.rb', line 10 def constants(where: {}) constants = store.constants case when where.key?(:refers_to) constants.select { |c| c.refers_to == where[:refers_to] } when where.key?(:caller) constants.select { |c| c.caller == where[:caller] } else constants end end |