Skip to content

Commit

Permalink
Merge pull request #167 from watermarkchurch/app-specific-site-config
Browse files Browse the repository at this point in the history
resolve site config constant before instantiating
  • Loading branch information
jpowell committed May 16, 2019
2 parents e738910 + 465377e commit c3c0c6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Expand Up @@ -46,10 +46,16 @@ def redirect_model
WCC::Contentful::Model.resolve_constant('redirect')
end

def global_site_config
def site_config_model
# They may have not installed `site-config` in the project
return unless defined?(WCC::Contentful::Model::SiteConfig)
WCC::Contentful::Model.resolve_constant('site-config')
rescue WCC::Contentful::ContentTypeNotFoundError
nil
end

def global_site_config
return unless model = site_config_model

@global_site_config ||= WCC::Contentful::Model::SiteConfig.instance(preview?)
@global_site_config ||= model.instance(preview?)
end
end
Expand Up @@ -224,7 +224,7 @@
.times(2)

# act
main_menu = store.find_all(content_type: 'menu')
store.find_all(content_type: 'menu')
.apply(name: 'Main Menu')
.first
end
Expand Down

0 comments on commit c3c0c6f

Please sign in to comment.