Class: Pageflow::PageTypes

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/pageflow/page_types.rb

Instance Method Summary collapse

Constructor Details

#initializePageTypes

Returns a new instance of PageTypes.



5
6
7
# File 'lib/pageflow/page_types.rb', line 5

def initialize
  clear
end

Instance Method Details

#clearObject



9
10
11
12
# File 'lib/pageflow/page_types.rb', line 9

def clear
  @page_types = []
  @page_types_by_name = {}
end

#each(&block) ⇒ Object



31
32
33
# File 'lib/pageflow/page_types.rb', line 31

def each(&block)
  @page_types.each(&block)
end

#find_by_name!(name) ⇒ Object



21
22
23
24
25
# File 'lib/pageflow/page_types.rb', line 21

def find_by_name!(name)
  @page_types_by_name.fetch(name) do
    raise "Unknown page type with name #{name}."
  end
end

#namesObject



27
28
29
# File 'lib/pageflow/page_types.rb', line 27

def names
  map(&:name)
end

#register(page_type) ⇒ Object



14
15
16
17
18
19
# File 'lib/pageflow/page_types.rb', line 14

def register(page_type)
  @page_types << page_type
  @page_types_by_name[page_type.name] = page_type

  ensure_export_version_implemented(page_type)
end

#setup(config) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/pageflow/page_types.rb', line 35

def setup(config)
  config.help_entries.register('pageflow.help_entries.page_types', priority: 10)
  each do |page_type|
    register_help_entries(config, page_type)
    register_revision_components(config, page_type)
    register_file_types(config, page_type)
  end
end