Class: ForestLiana::Bootstrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/forest_liana/bootstrapper.rb

Constant Summary collapse

SCHEMA_FILENAME =
File.join(Dir.pwd, '.forestadmin-schema.json')

Instance Method Summary collapse

Constructor Details

#initialize(reset_api_map = false) ⇒ Bootstrapper

Returns a new instance of Bootstrapper.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/forest_liana/bootstrapper.rb', line 8

def initialize(reset_api_map = false)
  if reset_api_map
    ForestLiana.apimap = []
    ForestLiana.models = []
  end

  @integration_stripe_valid = false
  @integration_intercom_valid = false

  if ForestLiana.secret_key && ForestLiana.auth_key
    FOREST_LOGGER.warn "DEPRECATION WARNING: The use of " \
      "ForestLiana.secret_key and ForestLiana.auth_key " \
      "(config/initializers/forest_liana.rb) is deprecated. Please use " \
      "ForestLiana.env_secret and ForestLiana.auth_secret instead."
    ForestLiana.env_secret = ForestLiana.secret_key
    ForestLiana.auth_secret = ForestLiana.auth_key
  end

  if ForestLiana.forest_client_id
    FOREST_LOGGER.warn "DEPRECATION WARNING: The use of " \
      "ForestLiana.forest_client_id is deprecated. It's not needed anymore."
  end

  unless Rails.application.config.action_controller.perform_caching || Rails.env.test?
    FOREST_LOGGER.error "You need to enable caching on your environment to use Forest Admin.\n" \
      "For a development environment, run: `rails dev:cache`"
  end

  fetch_models
  check_integrations_setup
  namespace_duplicated_models
  create_factories

  generate_apimap if ForestLiana.env_secret
end

Instance Method Details

#display_apimapObject



48
49
50
51
52
# File 'lib/forest_liana/bootstrapper.rb', line 48

def display_apimap
  if ForestLiana.env_secret
    puts " = Current Forest Apimap:\n#{JSON.pretty_generate(get_apimap_serialized)}"
  end
end

#synchronize(with_feedback = false) ⇒ Object



44
45
46
# File 'lib/forest_liana/bootstrapper.rb', line 44

def synchronize(with_feedback=false)
  send_apimap(with_feedback) if ForestLiana.env_secret
end