Class: Pageflow::EntryTypes

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

Overview

A collection of EntryType objects.

Since:

  • 15.1

Instance Method Summary collapse

Constructor Details

#initializeEntryTypes

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of EntryTypes.

Since:

  • 15.1



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

def initialize
  @entry_types_by_name = {}
end

Instance Method Details

#each(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 15.1



28
29
30
# File 'lib/pageflow/entry_types.rb', line 28

def each(&block)
  @entry_types_by_name.values.each(&block)
end

#find_by_name!(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 15.1



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

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

#register(entry_type) ⇒ Object

Register an entry type.

Parameters:

Since:

  • 15.1



16
17
18
# File 'lib/pageflow/entry_types.rb', line 16

def register(entry_type)
  @entry_types_by_name[entry_type.name] = entry_type
end

#routes(router) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 15.1



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/pageflow/entry_types.rb', line 33

def routes(router)
  each do |entry_type|
    next unless entry_type.editor_app

    router.instance_eval do
      nested do
        scope '/:entry_type', constraints: {entry_type: entry_type.name} do
          mount entry_type.editor_app, at: '/'
        end
      end
    end
  end
end