Module: SeoMeta::InstanceMethods

Defined in:
lib/seo_meta/instance_methods.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/seo_meta/instance_methods.rb', line 5

def included(base)
  # This has to be introduced using module_eval because it overrides something.
  base.module_eval do
    def seo_meta
      find_seo_meta_tags || build_seo_meta_tags
    end

    # Allow attributes supplied to override the current seo_meta_attributes.
    def attributes_with_seo_meta
      seo_meta_attributes.merge(attributes_without_seo_meta)
    end

    alias_method_chain :attributes, :seo_meta

    def attributes_equals_with_seo_meta(attributes, *args)
      seo_meta_attributes.merge(attributes)
      attributes_equals_without_seo_meta
    end

    alias_method :attributes_equals, :attributes=
    alias_method_chain :attributes_equals, :seo_meta
  end
end

Instance Method Details

#seo_meta_attributesObject


30
31
32
33
34
# File 'lib/seo_meta/instance_methods.rb', line 30

def seo_meta_attributes
  ::SeoMeta.attributes.keys.inject({}) { |attrs, name|
    attrs.merge(name.to_s => send(name))
  }
end