Module: WCC::Contentful::App

Defined in:
lib/wcc/contentful/app/version.rb,
lib/wcc/contentful/app/exceptions.rb,
app/mailers/wcc/contentful/app/contact_mailer.rb,
lib/wcc/contentful/app/custom_markdown_render.rb,
app/models/wcc/contentful/app/contact_form_submission.rb,
lib/wcc/contentful/app/engine.rb,
lib/wcc/contentful/app.rb

Defined Under Namespace

Modules: MenuHelper, PreviewPassword, SectionHelper Classes: Configuration, ContactFormController, ContactFormSubmission, ContactMailer, CustomMarkdownRender, Engine, MarkdownRenderer, PageNotFoundError, PagesController, ValidationError

Constant Summary collapse

VERSION =
'1.6.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject (readonly)

Gets the current configuration, after calling WCC::Contentful::App.configure



14
15
16
# File 'lib/wcc/contentful/app.rb', line 14

def configuration
  @configuration
end

.initializedObject (readonly)

Returns the value of attribute initialized.



11
12
13
# File 'lib/wcc/contentful/app.rb', line 11

def initialized
  @initialized
end

Class Method Details

.configureObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/wcc/contentful/app.rb', line 17

def self.configure
  if initialized || WCC::Contentful.initialized
    raise WCC::Contentful::InitializationError, 'Cannot configure after initialization'
  end

  WCC::Contentful.configure do |wcc_contentful_config|
    if @configuration&.wcc_contentful_config != wcc_contentful_config
      @configuration = Configuration.new(wcc_contentful_config)
    end
    yield(configuration)
  end

  configuration.validate!

  configuration
end

.db_connected?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/wcc/contentful/app.rb', line 59

def self.db_connected?
  @db_connected
end

.init!Object

Raises:

  • (ArgumentError)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/wcc/contentful/app.rb', line 34

def self.init!
  raise ArgumentError, 'Please first call WCC::Contentful::App.configure' if configuration.nil?

  WCC::Contentful.init!

  # Extend all model types w/ validation & extra fields
  WCC::Contentful::Model.schema.each_value do |t|
    file = File.dirname(__FILE__) + "/model/#{t.name.underscore}.rb"
    require file if File.exist?(file)
  end

  @db_connected =
    begin
      ::ActiveRecord::Base.connection_pool.with_connection(&:active?)
    rescue StandardError
      false
    end

  @configuration = WCC::Contentful::App::Configuration::FrozenConfiguration.new(
    configuration,
    WCC::Contentful.configuration
  )
  @initialized = true
end