Module: FiSeo::ClassMethods

Defined in:
lib/fi_seo.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_seoable(title, description, keywords, _options = {}) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/fi_seo.rb', line 72

def acts_as_seoable(title, description, keywords, _options = {})
  extend  ActsAsSeoableClassMethods
  include ActsAsSeoableInstanceMethods

  attr_names = [title, description, keywords]
  configuration = { check_for_changes: true,
                    reverse: false,
                    lowercase: false,
                    index: false,
                    noindex: false,
                    nofollow: false,
                    follow: false,
                    noarchive: false,
                    social: false,
                    separator: '|',
                    canonical: false }
  configuration.update(_options) if _options.present?
  configuration[:fields] = attr_names.flatten.uniq.compact

  class_attribute :seoable_options
  self.seoable_options = configuration

  self.send('after_create', :create_dynamic_seo_record)
  self.send('after_update', :update_dynamic_seo_record)
  self.send('has_one', :dynamic_seo, as: :seoable, dependent: :delete)
  self.send('accepts_nested_attributes_for', :dynamic_seo)
end