class Argyle::Page::Factory

Public Class Methods

new(layout_registry) click to toggle source

@param layout_registry [Argyle::Layout::Registry]

# File lib/argyle/page/factory.rb, line 4
def initialize(layout_registry)
  @layout_registry = layout_registry
end

Public Instance Methods

create(klass) click to toggle source

@param klass [Class<Argyle::Page::Base>] Subclass of Argyle::Page

@return [Argyle::Page::Base]

@raise [Argyle::Error::TypeError] If the page is not a subclass of Argyle::Page

# File lib/argyle/page/factory.rb, line 14
def create(klass)
  Argyle::Assert.klass(Argyle::Page::Base, klass)

  components = klass.component_prototypes.transform_values(&:unwrap)

  klass.new(
    components,
    @layout_registry.clone(klass.layout_id || :default)
  )
end