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.


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

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

Instance Attribute Details

#viewObject (readonly)

Returns the value of attribute view.


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

def view
  @view
end

Instance Method Details

#child(child_suffix) ⇒ Object


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

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

#children_tagsObject


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

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


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

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