Method: PageLayoutHelper#page_card_attributes

Defined in:
app/helpers/page_layout_helper.rb

#page_card_attributes(map = {}) ⇒ Object

Define or get attributes to be used as Twitter card metadata

map - Hash of label => data pairs. Keys become labels, values become data

Raises ArgumentError if given more than two attributes

Raises:

  • (ArgumentError)


73
74
75
76
77
78
79
# File 'app/helpers/page_layout_helper.rb', line 73

def page_card_attributes(map = {})
  raise ArgumentError, 'cannot provide more than two attributes' if map.length > 2

  @page_card_attributes ||= {}
  @page_card_attributes = map.reject { |_, v| v.blank? } if map.present?
  @page_card_attributes
end