Class: Pageflow::InternalLinks::PageLinks

Inherits:
Struct
  • Object
show all
Defined in:
app/helpers/pageflow/internal_links/page_links.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration

Returns:

  • (Object)

    the current value of configuration



3
4
5
# File 'app/helpers/pageflow/internal_links/page_links.rb', line 3

def configuration
  @configuration
end

#entryObject

Returns the value of attribute entry

Returns:

  • (Object)

    the current value of entry



3
4
5
# File 'app/helpers/pageflow/internal_links/page_links.rb', line 3

def entry
  @entry
end

#templateObject

Returns the value of attribute template

Returns:

  • (Object)

    the current value of template



3
4
5
# File 'app/helpers/pageflow/internal_links/page_links.rb', line 3

def template
  @template
end

Class Method Details

.deserialize(template, entry, configuration) ⇒ Object



4
5
6
# File 'app/helpers/pageflow/internal_links/page_links.rb', line 4

def self.deserialize(template, entry, configuration)
  new(template, entry, configuration).deserialize
end

Instance Method Details

#deserializeObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/helpers/pageflow/internal_links/page_links.rb', line 8

def deserialize
  page_links = parse

  pages_by_perma_id = entry.pages
    .where(perma_id: page_links.map(&:target_page_id))
    .index_by(&:perma_id)

  page_links.each do |page_link|
    page_link.target_page = pages_by_perma_id[page_link.target_page_id]
  end
end