Class: EacRailsUtils::OpenGraphProtocolHelper::AbstractEntry

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

Direct Known Subclasses

Entry, RootEntry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ AbstractEntry

Returns a new instance of AbstractEntry.



29
30
31
32
# File 'app/helpers/eac_rails_utils/open_graph_protocol_helper.rb', line 29

def initialize(view)
  @view = view
  @children = ::ActiveSupport::HashWithIndifferentAccess.new
end

Instance Attribute Details

#viewObject (readonly)

Returns the value of attribute view.



27
28
29
# File 'app/helpers/eac_rails_utils/open_graph_protocol_helper.rb', line 27

def view
  @view
end

Instance Method Details

#child(child_suffix) ⇒ Object



34
35
36
# File 'app/helpers/eac_rails_utils/open_graph_protocol_helper.rb', line 34

def child(child_suffix)
  @children[child_suffix] ||= Entry.new(view, self, child_suffix)
end

#children_tagsObject



38
39
40
41
42
43
44
45
46
# File 'app/helpers/eac_rails_utils/open_graph_protocol_helper.rb', line 38

def children_tags
  view.capture do
    view.concat tag
    @children.values.each do |child|
      view.concat(child.children_tags)
      view.concat("\n")
    end
  end
end

#data=(a_data) ⇒ Object



48
49
50
51
52
53
54
# File 'app/helpers/eac_rails_utils/open_graph_protocol_helper.rb', line 48

def data=(a_data)
  if a_data.is_a?(::Hash)
    a_data.each { |k, v| child(k).data = v }
  else
    self.content = a_data
  end
end