Module: AbAdmin::Models::Header

Extended by:
ActiveSupport::Concern
Included in:
Header
Defined in:
lib/ab_admin/models/header.rb

Instance Method Summary collapse

Instance Method Details

#empty?Boolean


13
14
15
# File 'lib/ab_admin/models/header.rb', line 13

def empty?
  [keywords, description, title].map(&:blank?).all?
end

#has_info?Boolean


17
18
19
# File 'lib/ab_admin/models/header.rb', line 17

def has_info?
  !empty?
end

#normalize_htmlObject


26
27
28
29
30
31
32
33
34
35
# File 'lib/ab_admin/models/header.rb', line 26

def normalize_html
  ::Globalize.available_locales.each do |loc|
    %w(title h1 keywords description).each do |attr|
      send("#{attr}_#{loc}=", send("#{attr}_#{loc}").to_s.no_html)
    end
  end
  ::Globalize.available_locales.each do |loc|
    send("seo_block_#{loc}=", sanitize(send("seo_block_#{loc}").to_s))
  end
end

#read(key) ⇒ Object


21
22
23
24
# File 'lib/ab_admin/models/header.rb', line 21

def read(key)
  value = read_attribute(key)
  value.blank? ? nil : value
end