cirandas.net

ref: master

plugins/open_graph/lib/open_graph_plugin/publisher.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class OpenGraphPlugin::Publisher

  def self.default
    @default ||= self.new
  end

  def initialize attributes = {}
    attributes.each do |attr, value|
      self.send "#{attr}=", value
    end
  end

  def publish_stories object_data, actor, stories
    stories.each do |story|
      begin
        self.publish_story object_data, actor, story
      rescue => e
        raise unless Rails.env.production?
        ExceptionNotifier.notify_exception e
      end
    end
  end

  def publish_story object_data, actor, story
    OpenGraphPlugin.context = OpenGraphPlugin::Activity.context
    a = OpenGraphPlugin::Activity.new object_data: object_data, actor: actor, story: story
    a.dispatch_publications
    a.save
  end

  protected

end