Module: ActiveRecord::Acts::Opengraph::InstanceMethods

Defined in:
lib/acts_as_opengraph/active_record/acts/opengraph.rb

Instance Method Summary collapse

Instance Method Details

#opengraph_dataArray

Returns an array of hashes representing the opengraph attribute/values for the Object.

Examples:

@movie.opengraph_data #=> {name=> "og:title", :value => "The Rock"}, {:name => "og:type", :value=> "movie"}

Returns:

  • (Array)

    List of hashes representing opengraph attribute/values



99
100
101
102
103
104
# File 'lib/acts_as_opengraph/active_record/acts/opengraph.rb', line 99

def opengraph_data
  data_list = opengraph_atts.map do |att_name|
    {:name => "og:#{att_name}", :value => self.send("opengraph_#{att_name}")}
  end
  data_list.delete_if{ |el| el[:value].blank?  }
end