Class: ActionTracer::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/action_tracer/filters.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, method:) ⇒ Action

Returns a new instance of Action.



37
38
39
40
# File 'lib/action_tracer/filters.rb', line 37

def initialize(name:, method:)
  @name = name
  @method = method
end

Class Method Details

.build(controller) ⇒ Object



42
43
44
45
# File 'lib/action_tracer/filters.rb', line 42

def self.build(controller)
  method = controller.respond_to?(controller.action_name) ? controller.method(controller.action_name) : nil_method
  new(name: controller.action_name, method: method)
end

Instance Method Details

#to_aObject



47
48
49
50
51
# File 'lib/action_tracer/filters.rb', line 47

def to_a
  source_location, line_number = *@method.source_location
  source_location = source_location&.sub(::ActionTracer.config.omitted_source_location_path, '')
  [APPLIED[:action], @name, source_location, line_number].compact
end