Class: I18n::Tasks::Scanners::PrismScanners::ParsedBeforeAction
- Defined in:
- lib/i18n/tasks/scanners/prism_scanners/nodes.rb
Instance Attribute Summary collapse
-
#except ⇒ Object
Returns the value of attribute except.
-
#name ⇒ Object
Returns the value of attribute name.
-
#only ⇒ Object
Returns the value of attribute only.
Attributes inherited from Root
#calls, #children, #file_path, #node, #parent, #rails, #translation_calls
Instance Method Summary collapse
- #applies_to?(method_name) ⇒ Boolean
-
#initialize(node:, parent:, name: nil, only: nil, except: nil) ⇒ ParsedBeforeAction
constructor
A new instance of ParsedBeforeAction.
- #path ⇒ Object
- #process ⇒ Object
- #support_relative_keys? ⇒ Boolean
Methods inherited from Root
#add_call, #add_child, #add_translation_call, #partial_view?, #private_method, #rails_view?, #support_candidate_keys?
Constructor Details
#initialize(node:, parent:, name: nil, only: nil, except: nil) ⇒ ParsedBeforeAction
Returns a new instance of ParsedBeforeAction.
363 364 365 366 367 368 369 |
# File 'lib/i18n/tasks/scanners/prism_scanners/nodes.rb', line 363 def initialize(node:, parent:, name: nil, only: nil, except: nil) @name = name @only = only.present? ? Array(only).map(&:to_s) : nil @except = except.present? ? Array(except).map(&:to_s) : nil super(node: node, parent: parent) end |
Instance Attribute Details
#except ⇒ Object
Returns the value of attribute except.
361 362 363 |
# File 'lib/i18n/tasks/scanners/prism_scanners/nodes.rb', line 361 def except @except end |
#name ⇒ Object
Returns the value of attribute name.
361 362 363 |
# File 'lib/i18n/tasks/scanners/prism_scanners/nodes.rb', line 361 def name @name end |
#only ⇒ Object
Returns the value of attribute only.
361 362 363 |
# File 'lib/i18n/tasks/scanners/prism_scanners/nodes.rb', line 361 def only @only end |
Instance Method Details
#applies_to?(method_name) ⇒ Boolean
375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/i18n/tasks/scanners/prism_scanners/nodes.rb', line 375 def applies_to?(method_name) if @only.nil? && @except.nil? true elsif @only.nil? !@except.include?(method_name.to_s) elsif @except.nil? @only.include?(method_name.to_s) else false end end |
#path ⇒ Object
387 388 389 |
# File 'lib/i18n/tasks/scanners/prism_scanners/nodes.rb', line 387 def path @parent&.path || [] end |
#process ⇒ Object
391 392 393 |
# File 'lib/i18n/tasks/scanners/prism_scanners/nodes.rb', line 391 def process @translation_calls.filter { |call| !call.relative_key? } end |
#support_relative_keys? ⇒ Boolean
371 372 373 |
# File 'lib/i18n/tasks/scanners/prism_scanners/nodes.rb', line 371 def support_relative_keys? false end |