Module: Spotlight::Resources::OpenGraph

Extended by:
ActiveSupport::Concern
Includes:
Web
Defined in:
app/models/concerns/spotlight/resources/open_graph.rb

Instance Method Summary collapse

Methods included from Web

#body, fetch, #harvest!

Instance Method Details

#opengraphObject



6
7
8
9
10
11
12
13
14
15
16
# File 'app/models/concerns/spotlight/resources/open_graph.rb', line 6

def opengraph
  @opengraph ||= begin
    page = Hash.new

    body.css('meta').select { |m| m.attribute('property') }.each do |m|
      page[m.attribute('property').to_s] = m.attribute('content').to_s
    end

    page
  end
end

#opengraph_propertiesObject



18
19
20
21
22
# File 'app/models/concerns/spotlight/resources/open_graph.rb', line 18

def opengraph_properties
  Hash[opengraph.map do |k,v|
    ["#{k.parameterize("_")}_tesim", v]
  end]
end

#to_solrObject



24
25
26
# File 'app/models/concerns/spotlight/resources/open_graph.rb', line 24

def to_solr
  super.merge(opengraph_properties)
end