Class: Busted::Profiler::Sandwich

Inherits:
Object
  • Object
show all
Includes:
Countable, Traceable, Singleton
Defined in:
lib/busted/profiler/sandwich.rb

Constant Summary collapse

VALID_ACTIONS =
[:start, :finish].freeze

Instance Attribute Summary collapse

Attributes included from Countable

#counter

Attributes included from Traceable

#tracer

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Countable

#finish_counter, #start_counter

Methods included from Traceable

#finish_tracer, #start_tracer, #trace?

Instance Attribute Details

#actionObject

Returns the value of attribute action.



14
15
16
# File 'lib/busted/profiler/sandwich.rb', line 14

def action
  @action
end

#reportObject (readonly)

Returns the value of attribute report.



15
16
17
# File 'lib/busted/profiler/sandwich.rb', line 15

def report
  @report
end

#traceObject

Returns the value of attribute trace.



15
16
17
# File 'lib/busted/profiler/sandwich.rb', line 15

def trace
  @trace
end

Class Method Details

.run(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/busted/profiler/sandwich.rb', line 17

def self.run(options = {})
  action = options.fetch :action, false
  trace = options.fetch :trace, false

  unless VALID_ACTIONS.include? action
    fail ArgumentError, "profiler requires start or finish action"
  end

  sandwich = instance

  sandwich.action = action
  sandwich.trace = trace
  sandwich.run
end

Instance Method Details

#runObject



32
33
34
# File 'lib/busted/profiler/sandwich.rb', line 32

def run
  send action
end