Class: Ecoportal::API::GraphQL::Model::PageUnion
- Inherits:
-
Object
- Object
- Ecoportal::API::GraphQL::Model::PageUnion
- Defined in:
- lib/ecoportal/api/graphql/model/page_union.rb
Overview
Factory class — dispatches on __typename to the correct concrete page class.
Must be a Class (not a Module): v2's resolve_class matches when Class, so a
Module target falls through to "Unknown class". self.new is overridden to
return the concrete page instance instead of a PageUnion instance.
Class Method Summary collapse
Class Method Details
.new(doc, **opts) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/ecoportal/api/graphql/model/page_union.rb', line 10 def self.new(doc, **opts) case doc&.fetch('__typename', nil) when 'BasicPage' then Page::Basic.new(doc, **opts) when 'PhasedPage' then Page::Phased.new(doc, **opts) else Interface::BasePage.new(doc, **opts) end end |