Class: EacRailsUtils::OpenGraphProtocolHelper::Entry

Inherits:
AbstractEntry
  • Object
show all
Defined in:
app/helpers/eac_rails_utils/open_graph_protocol_helper.rb

Instance Attribute Summary collapse

Attributes inherited from AbstractEntry

#view

Instance Method Summary collapse

Methods inherited from AbstractEntry

#child, #children_tags, #data=

Constructor Details

#initialize(view, parent, suffix) ⇒ Entry

Returns a new instance of Entry.


61
62
63
64
65
# File 'app/helpers/eac_rails_utils/open_graph_protocol_helper.rb', line 61

def initialize(view, parent, suffix)
  super view
  @parent = parent
  @suffix = suffix
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.


59
60
61
# File 'app/helpers/eac_rails_utils/open_graph_protocol_helper.rb', line 59

def parent
  @parent
end

#suffixObject (readonly)

Returns the value of attribute suffix.


59
60
61
# File 'app/helpers/eac_rails_utils/open_graph_protocol_helper.rb', line 59

def suffix
  @suffix
end

Instance Method Details

#componentsObject


67
68
69
# File 'app/helpers/eac_rails_utils/open_graph_protocol_helper.rb', line 67

def components
  (parent.present? ? parent.components : []) + [suffix]
end

#contentObject


71
72
73
# File 'app/helpers/eac_rails_utils/open_graph_protocol_helper.rb', line 71

def content
  view.content_for content_for_key
end

#content=(a_content) ⇒ Object


75
76
77
# File 'app/helpers/eac_rails_utils/open_graph_protocol_helper.rb', line 75

def content=(a_content)
  view.content_for content_for_key, a_content.to_s
end

#content?Boolean

Returns:

  • (Boolean)

79
80
81
# File 'app/helpers/eac_rails_utils/open_graph_protocol_helper.rb', line 79

def content?
  view.content_for? content_for_key
end

#content_for_keyObject


83
84
85
# File 'app/helpers/eac_rails_utils/open_graph_protocol_helper.rb', line 83

def content_for_key
  "ogp_#{components.join('_')}"
end

#property_valueObject


87
88
89
# File 'app/helpers/eac_rails_utils/open_graph_protocol_helper.rb', line 87

def property_value
  "#{view.ogp_meta_prefix}:#{components.join(':')}"
end

#tagObject


91
92
93
94
95
# File 'app/helpers/eac_rails_utils/open_graph_protocol_helper.rb', line 91

def tag
  return ::ActiveSupport::SafeBuffer.new unless content?

  view.tag(:meta, prefix: view.ogp_prefix, property: property_value, content: content)
end