module IntegrationPal class Worker < ApplicationRecord include ActiveModel store :settings, coder: Hash attr_encrypted :settings, key: ENV['ENCRYPTION_KEY'], salt: ENV['SALT_KEY'], marshal: true validates :name, presence: true validates :access_id, presence: true validates :secret_key, presence: true validates :job_type, presence: true has_many :jobs before_create :generate_api_key def generate_api_key ApiAuth.generate_secret_key end after_initialize do |user| self.settings ||= {} self.secret_key ||= ApiAuth.generate_secret_key end def job_class self.job_type.constantize end end end