Top Level Namespace
Defined Under Namespace
Modules: SeoMeta Classes: SeoMetaGenerator, SeoMetum
Instance Method Summary collapse
Instance Method Details
#is_seo_meta(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/seo_meta.rb', line 21 def ( = {}) if included_modules.exclude?(::SeoMeta::InstanceMethods) # Let the base know about SeoMetum = { :class_name => 'SeoMetum', :foreign_key => :seo_meta_id, :dependent => :destroy }.merge(.slice(:class_name, :foreign_key, :dependent)) has_one :seo_meta, -> { where(:seo_meta_type => self.name) }, ** # Let SeoMetum know about the base ::SeoMetum.send :belongs_to, self.name.underscore.gsub('/', '_').to_sym, class_name: self.name, optional: true # Include the instance methods. self.send :include, ::SeoMeta::InstanceMethods # Ensure that seo_meta is saved after the model is saved. after_save :save_meta_tags! end # Delegate both the accessor and setters for the fields to :seo_meta fields = ::SeoMeta.attributes.keys.map{|a| [a, :"#{a}="]}.flatten delegate *fields, to: :seo_meta end |