Class: DestroySoon::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/destroy_soon/job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Job

Returns a new instance of Job.



4
5
6
7
# File 'lib/destroy_soon/job.rb', line 4

def initialize(opts)
  @entity_id = opts[:entity].id
  @entity_klass = opts[:entity].class.to_s
end

Instance Attribute Details

#entity_idObject

Returns the value of attribute entity_id.



3
4
5
# File 'lib/destroy_soon/job.rb', line 3

def entity_id
  @entity_id
end

#entity_klassObject

Returns the value of attribute entity_klass.



3
4
5
# File 'lib/destroy_soon/job.rb', line 3

def entity_klass
  @entity_klass
end

Instance Method Details

#entityObject



13
14
15
# File 'lib/destroy_soon/job.rb', line 13

def entity
  entity_klass.constantize.find_by_id(entity_id)
end

#performObject



9
10
11
# File 'lib/destroy_soon/job.rb', line 9

def perform
  entity.try(:destroy)
end