Class: PlatformosCheck::UndefinedObject::TemplateInfo
- Inherits:
-
Object
- Object
- PlatformosCheck::UndefinedObject::TemplateInfo
- Defined in:
- lib/platformos_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.
-
#app_file ⇒ Object
readonly
Returns the value of attribute app_file.
Instance Method Summary collapse
- #add_render(name:, node:) ⇒ Object
- #add_variable_lookup(name:, node:) ⇒ Object
- #all_variables ⇒ Object
- #each_partial ⇒ Object
- #each_variable_lookup(unique_keys = false) ⇒ Object
-
#initialize(app_file: nil) ⇒ TemplateInfo
constructor
A new instance of TemplateInfo.
Constructor Details
#initialize(app_file: nil) ⇒ TemplateInfo
10 11 12 13 14 15 16 17 |
# File 'lib/platformos_check/checks/undefined_object.rb', line 10 def initialize(app_file: nil) @all_variable_lookups = {} @all_assigns = {} @all_captures = {} @all_forloops = {} @all_renders = {} @app_file = app_file end |
Instance Attribute Details
#all_assigns ⇒ Object (readonly)
Returns the value of attribute all_assigns.
19 20 21 |
# File 'lib/platformos_check/checks/undefined_object.rb', line 19 def all_assigns @all_assigns end |
#all_captures ⇒ Object (readonly)
Returns the value of attribute all_captures.
19 20 21 |
# File 'lib/platformos_check/checks/undefined_object.rb', line 19 def all_captures @all_captures end |
#all_forloops ⇒ Object (readonly)
Returns the value of attribute all_forloops.
19 20 21 |
# File 'lib/platformos_check/checks/undefined_object.rb', line 19 def all_forloops @all_forloops end |
#app_file ⇒ Object (readonly)
Returns the value of attribute app_file.
19 20 21 |
# File 'lib/platformos_check/checks/undefined_object.rb', line 19 def app_file @app_file end |
Instance Method Details
#add_render(name:, node:) ⇒ Object
21 22 23 |
# File 'lib/platformos_check/checks/undefined_object.rb', line 21 def add_render(name:, node:) @all_renders[name] = node end |
#add_variable_lookup(name:, node:) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/platformos_check/checks/undefined_object.rb', line 25 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
37 38 39 |
# File 'lib/platformos_check/checks/undefined_object.rb', line 37 def all_variables all_assigns.keys + all_captures.keys + all_forloops.keys end |
#each_partial ⇒ Object
41 42 43 44 45 |
# File 'lib/platformos_check/checks/undefined_object.rb', line 41 def each_partial @all_renders.each do |(name, info)| yield [name, info] end end |
#each_variable_lookup(unique_keys = false) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/platformos_check/checks/undefined_object.rb', line 47 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 |