Class: TagJob

Inherits:
Struct
  • Object
show all
Defined in:
app/models/job/tag_job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag, people) ⇒ TagJob

Returns a new instance of TagJob.



2
3
4
5
# File 'app/models/job/tag_job.rb', line 2

def initialize(tag, people)
  self.tag = tag
  self.people_ids = Array.wrap(people).map(&:id)
end

Instance Attribute Details

#people_idsObject

Returns the value of attribute people_ids

Returns:

  • (Object)

    the current value of people_ids



1
2
3
# File 'app/models/job/tag_job.rb', line 1

def people_ids
  @people_ids
end

#tagObject

Returns the value of attribute tag

Returns:

  • (Object)

    the current value of tag



1
2
3
# File 'app/models/job/tag_job.rb', line 1

def tag
  @tag
end

Instance Method Details

#performObject



7
8
9
10
11
12
13
14
# File 'app/models/job/tag_job.rb', line 7

def perform
  Person.where(:id => self.people_ids).each do |p|
    p.tag_list << self.tag unless p.tag_list.include? self.tag
    p.skip_commit = true
    p.save
  end
  Sunspot.delay.commit
end