Module: Model::Tag
- Extended by:
- ActiveSupport::Concern
- Included in:
- Wechat::Tag
- Defined in:
- app/models/wechat/model/tag.rb
Constant Summary collapse
- SYS_TAG =
['2'].freeze
Instance Method Summary collapse
- #can_destroy? ⇒ Boolean
- #remove_from_wechat ⇒ Object
- #sync_name ⇒ Object
- #sync_to_wechat ⇒ Object
- #sync_to_wechat_later ⇒ Object
Instance Method Details
#can_destroy? ⇒ Boolean
51 52 53 |
# File 'app/models/wechat/model/tag.rb', line 51 def can_destroy? SYS_TAG.include?(tag_id) end |
#remove_from_wechat ⇒ Object
45 46 47 48 49 |
# File 'app/models/wechat/model/tag.rb', line 45 def remove_from_wechat app.api.tag_delete(self.tag_id) rescue Wechat::WechatError => e logger.info e. end |
#sync_name ⇒ Object
28 29 30 |
# File 'app/models/wechat/model/tag.rb', line 28 def sync_name self.name = tagging.name if tagging end |
#sync_to_wechat ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'app/models/wechat/model/tag.rb', line 36 def sync_to_wechat r = app.api.tag_create(self.name, self.tag_id) return unless r self.tag_id = r.dig('tag', 'id') self.save rescue Wechat::WechatError => e logger.info e. end |
#sync_to_wechat_later ⇒ Object
32 33 34 |
# File 'app/models/wechat/model/tag.rb', line 32 def sync_to_wechat_later TagJob.perform_later(self) end |