Class: ThemeCheck::UndefinedObject::TemplateInfo
- Inherits:
-
Object
- Object
- ThemeCheck::UndefinedObject::TemplateInfo
- Defined in:
- lib/theme_check/checks/undefined_object.rb
Instance Attribute Summary collapse
-
#all_assigns ⇒ Object
readonly
Returns the value of attribute all_assigns.
-
#all_captures ⇒ Object
readonly
Returns the value of attribute all_captures.
-
#all_forloops ⇒ Object
readonly
Returns the value of attribute all_forloops.
Instance Method Summary collapse
- #add_render(name:, node:) ⇒ Object
- #add_variable_lookup(name:, node:) ⇒ Object
- #all_variables ⇒ Object
- #each_snippet ⇒ Object
- #each_variable_lookup(unique_keys = false) ⇒ Object
-
#initialize ⇒ TemplateInfo
constructor
A new instance of TemplateInfo.
Constructor Details
#initialize ⇒ TemplateInfo
Returns a new instance of TemplateInfo.
9 10 11 12 13 14 15 |
# File 'lib/theme_check/checks/undefined_object.rb', line 9 def initialize @all_variable_lookups = {} @all_assigns = {} @all_captures = {} @all_forloops = {} @all_renders = {} end |
Instance Attribute Details
#all_assigns ⇒ Object (readonly)
Returns the value of attribute all_assigns.
17 18 19 |
# File 'lib/theme_check/checks/undefined_object.rb', line 17 def all_assigns @all_assigns end |
#all_captures ⇒ Object (readonly)
Returns the value of attribute all_captures.
17 18 19 |
# File 'lib/theme_check/checks/undefined_object.rb', line 17 def all_captures @all_captures end |
#all_forloops ⇒ Object (readonly)
Returns the value of attribute all_forloops.
17 18 19 |
# File 'lib/theme_check/checks/undefined_object.rb', line 17 def all_forloops @all_forloops end |
Instance Method Details
#add_render(name:, node:) ⇒ Object
19 20 21 |
# File 'lib/theme_check/checks/undefined_object.rb', line 19 def add_render(name:, node:) @all_renders[name] = node end |
#add_variable_lookup(name:, node:) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/theme_check/checks/undefined_object.rb', line 23 def add_variable_lookup(name:, node:) parent = node line_number = nil loop do line_number = parent.line_number parent = parent.parent break unless line_number.nil? && parent end key = [name, line_number] @all_variable_lookups[key] = node end |
#all_variables ⇒ Object
35 36 37 |
# File 'lib/theme_check/checks/undefined_object.rb', line 35 def all_variables all_assigns.keys + all_captures.keys + all_forloops.keys end |
#each_snippet ⇒ Object
39 40 41 42 43 |
# File 'lib/theme_check/checks/undefined_object.rb', line 39 def each_snippet @all_renders.each do |(name, info)| yield [name, info] end end |
#each_variable_lookup(unique_keys = false) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/theme_check/checks/undefined_object.rb', line 45 def each_variable_lookup(unique_keys = false) seen = Set.new @all_variable_lookups.each do |(key, info)| name, _line_number = key next if unique_keys && seen.include?(name) seen << name yield [key, info] end end |