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.



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

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

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



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

def parent
  @parent
end

#suffixObject (readonly)

Returns the value of attribute suffix.



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

def suffix
  @suffix
end

Instance Method Details

#componentsObject



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

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

#contentObject



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

def content
  view.content_for content_for_key
end

#content=(a_content) ⇒ Object



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

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

#content?Boolean

Returns:

  • (Boolean)


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

def content?
  view.content_for? content_for_key
end

#content_for_keyObject



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

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

#property_valueObject



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

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

#tagObject



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

def tag
  return ::ActiveSupport::SafeBuffer.new unless content?
  view.tag(:meta, prefix: view.ogp_prefix, property: property_value, content: content)
end