Class: ArticleServices::Synchronize

Inherits:
Object
  • Object
show all
Defined in:
app/service_objects/article_services/synchronize.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(article) ⇒ Synchronize


8
9
10
# File 'app/service_objects/article_services/synchronize.rb', line 8

def initialize(article)
  @article = article
end

Instance Attribute Details

#articleObject (readonly)

Returns the value of attribute article


6
7
8
# File 'app/service_objects/article_services/synchronize.rb', line 6

def article
  @article
end

Class Method Details

.call(begin_date, end_date) ⇒ Object


21
22
23
24
25
# File 'app/service_objects/article_services/synchronize.rb', line 21

def call(begin_date, end_date)
  Article.where('created_at > ? AND created_at < ?', begin_date, end_date).each do |a|
    new(a).delay.call
  end
end

Instance Method Details

#callObject


12
13
14
15
16
17
18
# File 'app/service_objects/article_services/synchronize.rb', line 12

def call
  article.facebook  = facebook(article.uri)
  article.linkedin  = linkedin(article.uri)
  article.twitter   = twitter(article.uri)

  article.save
end