Class: Perron::Metatags

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TagHelper
Defined in:
lib/perron/metatags.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Metatags

Returns a new instance of Metatags.



7
8
9
# File 'lib/perron/metatags.rb', line 7

def initialize(data)
  @data = data
end

Instance Method Details

#render(options = {}) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/perron/metatags.rb', line 11

def render(options = {})
  keys = tags.keys
    .then { options[:only] ? it & options[:only].map(&:to_sym) : it }
    .then { options[:except] ? it - options[:except].map(&:to_sym) : it }

  safe_join(keys.filter_map { tags[it].presence }, "\n")
end