Class: Graphlyte::Editors::CollectVariableReferences
- Inherits:
-
Object
- Object
- Graphlyte::Editors::CollectVariableReferences
- Defined in:
- lib/graphlyte/editors/collect_variable_references.rb
Overview
Find all variable references in a document
Instance Attribute Summary collapse
-
#references ⇒ Object
readonly
Returns the value of attribute references.
Instance Method Summary collapse
- #collector ⇒ Object
- #edit(doc) ⇒ Object
-
#initialize ⇒ CollectVariableReferences
constructor
A new instance of CollectVariableReferences.
Constructor Details
#initialize ⇒ CollectVariableReferences
Returns a new instance of CollectVariableReferences.
14 15 16 |
# File 'lib/graphlyte/editors/collect_variable_references.rb', line 14 def initialize @references = { Syntax::Operation => {}, Syntax::Fragment => {} } end |
Instance Attribute Details
#references ⇒ Object (readonly)
Returns the value of attribute references.
12 13 14 |
# File 'lib/graphlyte/editors/collect_variable_references.rb', line 12 def references @references end |
Instance Method Details
#collector ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/graphlyte/editors/collect_variable_references.rb', line 27 def collector Editor.new.on_variable_reference do |ref, action| d = action.definition references[d.class][d.name] ||= [].to_set references[d.class][d.name] << ref end end |
#edit(doc) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/graphlyte/editors/collect_variable_references.rb', line 18 def edit(doc) doc = doc.dup InlineFragments.new.edit(doc) collector.edit(doc) references end |