Class: ActiveSeo::SeoMeta
- Inherits:
-
Object
- Object
- ActiveSeo::SeoMeta
- Defined in:
- lib/active_seo/seo_meta.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#context ⇒ Object
Returns the value of attribute context.
-
#record ⇒ Object
Returns the value of attribute record.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(record) ⇒ SeoMeta
constructor
Initializer method.
- #keywords ⇒ Object
- #nofollow ⇒ Object
- #noindex ⇒ Object
- #og ⇒ Object
-
#result ⇒ Object
Set base seo meta.
- #title ⇒ Object
- #twitter ⇒ Object
Constructor Details
#initialize(record) ⇒ SeoMeta
Initializer method
6 7 8 9 10 |
# File 'lib/active_seo/seo_meta.rb', line 6 def initialize(record) @record = record @config = record.class.seo_config @context = contextualizer.new(record) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
3 4 5 |
# File 'lib/active_seo/seo_meta.rb', line 3 def config @config end |
#context ⇒ Object
Returns the value of attribute context.
3 4 5 |
# File 'lib/active_seo/seo_meta.rb', line 3 def context @context end |
#record ⇒ Object
Returns the value of attribute record.
3 4 5 |
# File 'lib/active_seo/seo_meta.rb', line 3 def record @record end |
Instance Method Details
#description ⇒ Object
25 26 27 28 29 30 |
# File 'lib/active_seo/seo_meta.rb', line 25 def description attribute = :seo_description defaults = [:content, :description, :excerpt, :body] attribute_fallbacks_for(attribute, defaults, config.description_fallback) end |
#keywords ⇒ Object
32 33 34 35 36 37 |
# File 'lib/active_seo/seo_meta.rb', line 32 def keywords text = record.try :seo_keywords text = "#{title} #{description}" if generate_keywords?(text) helpers.generate_keywords(text) end |
#nofollow ⇒ Object
43 44 45 |
# File 'lib/active_seo/seo_meta.rb', line 43 def nofollow record.seo_nofollow || false end |
#noindex ⇒ Object
39 40 41 |
# File 'lib/active_seo/seo_meta.rb', line 39 def noindex record.seo_noindex || false end |
#og ⇒ Object
47 48 49 |
# File 'lib/active_seo/seo_meta.rb', line 47 def og @config.opengraph.merge(context.) end |
#result ⇒ Object
Set base seo meta
13 14 15 16 |
# File 'lib/active_seo/seo_meta.rb', line 13 def result data = [:title, :description, :keywords, :noindex, :nofollow, :og, :twitter] Hash[data.map { |i| [i, send(i)] }] end |
#title ⇒ Object
18 19 20 21 22 23 |
# File 'lib/active_seo/seo_meta.rb', line 18 def title attribute = :seo_title defaults = [:title, :name] attribute_fallbacks_for(attribute, defaults, config.title_fallback) end |
#twitter ⇒ Object
51 52 53 |
# File 'lib/active_seo/seo_meta.rb', line 51 def twitter @config.twitter.merge(context.) end |