Class: I18n::Tasks::Scanners::PrismScanners::ParsedBeforeAction

Inherits:
Root
  • Object
show all
Defined in:
lib/i18n/tasks/scanners/prism_scanners/nodes.rb

Instance Attribute Summary collapse

Attributes inherited from Root

#calls, #children, #file_path, #node, #parent, #rails, #translation_calls

Instance Method Summary collapse

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

#exceptObject

Returns the value of attribute except.



361
362
363
# File 'lib/i18n/tasks/scanners/prism_scanners/nodes.rb', line 361

def except
  @except
end

#nameObject

Returns the value of attribute name.



361
362
363
# File 'lib/i18n/tasks/scanners/prism_scanners/nodes.rb', line 361

def name
  @name
end

#onlyObject

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

Returns:

  • (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

#pathObject



387
388
389
# File 'lib/i18n/tasks/scanners/prism_scanners/nodes.rb', line 387

def path
  @parent&.path || []
end

#processObject



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

Returns:

  • (Boolean)


371
372
373
# File 'lib/i18n/tasks/scanners/prism_scanners/nodes.rb', line 371

def support_relative_keys?
  false
end