Class: WCC::Contentful::Middleman::Extension
- Inherits:
-
Middleman::Extension
- Object
- Middleman::Extension
- WCC::Contentful::Middleman::Extension
- Defined in:
- lib/wcc/contentful/middleman/extension.rb
Defined Under Namespace
Classes: ContentfulSyncUpdate
Instance Method Summary collapse
-
#initialize(app, options_hash = {}, &block) ⇒ Extension
constructor
A new instance of Extension.
-
#ready ⇒ Object
helpers do def a_helper end end.
Constructor Details
#initialize(app, options_hash = {}, &block) ⇒ Extension
Returns a new instance of Extension.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/wcc/contentful/middleman/extension.rb', line 20 def initialize(app, = {}, &block) # don't pass block to super b/c we use it to configure WCC::Contentful super(app, ) {} # rubocop:disable Lint/EmptyBlock # Require libraries only when activated require 'wcc/contentful' # set up your extension return if WCC::Contentful.initialized WCC::Contentful.configure do |config| config.store :eager_sync, :memory .to_h.each do |(k, v)| config.public_send("#{k}=", v) if config.respond_to?("#{k}=") end # TODO: create MiddlemanRichTextRenderer and set as default here instance_exec(config, &block) if block_given? end WCC::Contentful.init! model_glob = File.join(Middleman::Application.root, 'lib/models/**/*.rb') Dir[model_glob].sort.each { |f| require f } # Sync the latest data from Contentful WCC::Contentful::Services.instance.sync_engine&.next end |
Instance Method Details
#ready ⇒ Object
helpers do
def a_helper
end
end
55 56 57 58 |
# File 'lib/wcc/contentful/middleman/extension.rb', line 55 def ready # resync every page load in development & test mode only app.use ContentfulSyncUpdate if app.server? end |