Class: Libis::Workflow::ActiveRecord::Job
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Libis::Workflow::ActiveRecord::Job
- Includes:
- Base, Base::Job
- Defined in:
- lib/libis/workflow/activerecord/job.rb
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
index(1, workflow_type: 1, name: 1, ‘by_workflow’).
Instance Method Summary collapse
-
#execute(opts = {}) ⇒ Object
noinspection RubyStringKeysInHashInspection.
- #logger ⇒ Object
Methods included from Base
Class Method Details
.from_hash(hash) ⇒ Object
index(1, workflow_type: 1, name: 1, ‘by_workflow’)
23 24 25 26 27 |
# File 'lib/libis/workflow/activerecord/job.rb', line 23 def self.from_hash(hash) self.create_from_hash(hash, [:name]) do |item, cfg| item.workflow = Libis::Workflow::ActiveRecord::Workflow.from_hash(name: cfg.delete('workflow')) end end |
Instance Method Details
#execute(opts = {}) ⇒ Object
noinspection RubyStringKeysInHashInspection
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/libis/workflow/activerecord/job.rb', line 52 def execute(opts = {}) opts['run_config'] ||= {} if self.log_each_run opts['run_config']['log_to_file'] = true opts['run_config']['log_level'] = self.log_level end if (run_name = opts.delete('run_name')) opts['run_config']['run_name'] = run_name end super opts end |
#logger ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/libis/workflow/activerecord/job.rb', line 29 def logger # noinspection RubyResolve return ::Libis::Workflow::ActiveRecord::Config.logger unless self.log_to_file logger = ::Logging::Repository.instance[self.name] return logger if logger unless ::Logging::Appenders[self.name] ::Logging::Appenders::RollingFile.new( self.name, filename: File.join(::Libis::Workflow::ActiveRecord::Config[:log_dir], "#{self.name}.{{%Y%m%d}}.log"), layout: ::Libis::Workflow::ActiveRecord::Config.get_log_formatter, truncate: true, age: self.log_age, keep: self.log_keep, roll_by: 'date', level: self.log_level ) end logger = ::Libis::Workflow::ActiveRecord::Config.logger(self.name, self.name) logger.additive = false logger end |