Class: RailsExecution::Services::Execution

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_execution/services/execution.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task) ⇒ Execution

Returns a new instance of Execution.



9
10
11
# File 'lib/rails_execution/services/execution.rb', line 9

def initialize(task)
  @task = task
end

Class Method Details

.call(task_id) ⇒ Object



5
6
7
# File 'lib/rails_execution/services/execution.rb', line 5

def self.call(task_id)
  self.new(::RailsExecution::Task.find(task_id)).call
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rails_execution/services/execution.rb', line 13

def call
  return if bad_syntax?

  build_execution_file!
  load_execution_file!
  is_successful = false
  begin
    setup_logger!
    execute_class!
    is_successful = true
  rescue
    is_successful = false
  ensure
    restore_logger!
    storing_log_file!
    return is_successful
  end
end