class Object

Public Class Methods

lev_handler(options={}) click to toggle source
# File lib/lev/object.rb, line 37
def self.lev_handler(options={})
  class_eval do
    include Lev::Handler
  end

  # Do routine configuration
  options[:skip_routine_include] = true
  lev_routine(options)

  # Do handler configuration (none currently)
end
lev_routine(options={}) click to toggle source
# File lib/lev/object.rb, line 3
def self.lev_routine(options={})
  class_eval do
    include Lev::Routine unless options[:skip_routine_include]

    # Routine configuration
    options[:transaction] ||= Lev::TransactionIsolation.mysql_default.symbol
    @transaction_isolation = Lev::TransactionIsolation.new(options[:transaction])

    @job_class = options[:job_class]
    @active_job_enqueue_options = options[:active_job_enqueue_options]

    @raise_fatal_errors = options[:raise_fatal_errors]

    @delegates_to = options[:delegates_to]
    if @delegates_to
      uses_routine @delegates_to,
                   translations: {
                     outputs: { type: :verbatim },
                     inputs: { type: :verbatim }
                   }

      @express_output ||= @delegates_to.express_output
    end

    # Set this after dealing with "delegates_to" in case it set a value
    @express_output ||= options[:express_output] || self.name.demodulize.underscore

    if options[:use_jobba]
      self.create_status_proc = ->(*) { Jobba::Status.create! }
      self.find_status_proc = ->(id) { Jobba::Status.find!(id) }
    end
  end
end

Public Instance Methods

handler_errors() click to toggle source
# File lib/lev/handler_helper.rb, line 1
def handler_errors
  @errors || (@handler_result ? @handler_result.errors : Lev::Errors.new)
end
lev_form_for(record_or_name_or_array, *args, &proc) click to toggle source
# File lib/lev/form_builder.rb, line 60
def lev_form_for(record_or_name_or_array, *args, &proc)
  options = args.extract_options!
  options[:params] = params
  options[:errors] = handler_errors # @errors || (@handler_outcome ? @handler_outcome.errors : [])
  form_for(record_or_name_or_array, *(args << options.merge(:builder => Lev::FormBuilder)), &proc)
end