Class: ForestLiana::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/forest_liana/engine.rb

Instance Method Summary collapse

Instance Method Details

#configure_forest_corsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/forest_liana/engine.rb', line 15

def configure_forest_cors
  begin
    rack_cors_class = Rack::Cors
    rack_cors_class = 'Rack::Cors' if Rails::VERSION::MAJOR < 5

    config.middleware.insert_before 0, rack_cors_class do
      allow do
        hostnames = ['localhost:4200', /\A.*\.forestadmin\.com\z/]
        hostnames += ENV['CORS_ORIGINS'].split(',') if ENV['CORS_ORIGINS']

        origins hostnames
        resource '*', headers: :any, methods: :any
      end
    end
    nil
  rescue => exception
    exception
  end
end

#rake?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/forest_liana/engine.rb', line 35

def rake?
  File.basename($0) == 'rake'
end