Module: Ext::UserTag

Extended by:
ActiveSupport::Concern
Defined in:
app/models/wechat/ext/user_tag.rb

Instance Method Summary collapse

Instance Method Details

#appObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/wechat/ext/user_tag.rb', line 23

def app
  if self.respond_to? :organ_id
    _organ_id = organ_id
  else
    _organ_id = nil
  end

  if App.column_names.include?('organ_id')
    App.find_by(organ_id: _organ_id, primary: true)
  else
    App.find_by(primary: true)
  end
end

#sync_tagObject



15
16
17
18
19
20
21
# File 'app/models/wechat/ext/user_tag.rb', line 15

def sync_tag
  _app = app
  return unless _app
  wt = tags.find_or_initialize_by(appid: _app.appid)
  wt.name = self.name
  wt.save
end

#sync_tag_laterObject



11
12
13
# File 'app/models/wechat/ext/user_tag.rb', line 11

def sync_tag_later
  Wechat::TagJob.perform_later(self)
end