Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/apartment/delayed_job/active_record.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.yaml_new(klass, tag, val) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/apartment/delayed_job/active_record.rb', line 7

def self.yaml_new(klass, tag, val)
  Apartment::Database.process(val['database']) do
    klass.find(val['attributes']['id'])
  end
rescue ActiveRecord::RecordNotFound => e
  raise Delayed::DeserializationError,  e.message
end

Instance Method Details

#encode_with_with_database(coder) ⇒ Object

Rails > 3.0 now uses encode_with to determine what to encode with yaml



17
18
19
20
# File 'lib/apartment/delayed_job/active_record.rb', line 17

def encode_with_with_database(coder)
  coder['database'] = @database if @database.present?
  encode_with_without_database(coder)
end

#to_yaml_propertiesObject

Remain backwards compatible with old yaml serialization



24
25
26
# File 'lib/apartment/delayed_job/active_record.rb', line 24

def to_yaml_properties
  ['@attributes', '@database']    # add in database attribute for serialization
end