Module: BetterSeo::Rails::ModelHelpers

Extended by:
ActiveSupport::Concern
Defined in:
lib/better_seo/rails/model_helpers.rb

Instance Method Summary collapse

Instance Method Details

#to_seo_hashObject

Convert model to SEO hash



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/better_seo/rails/model_helpers.rb', line 34

def to_seo_hash
  mappings = self.class.seo_attribute_mappings
  return {} if mappings.empty?

  hash = {}

  mappings.each_key do |seo_attr|
    value = send("seo_#{seo_attr}")
    hash[seo_attr] = value if value
  end

  hash
end