Class: Cors::Config
- Inherits:
-
Object
- Object
- Cors::Config
- Defined in:
- lib/cors/config.rb,
lib/cors/config/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.2.6"
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#user_config ⇒ Object
Returns the value of attribute user_config.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, user_config = 'config/cors.yml') ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(app, user_config = 'config/cors.yml') ⇒ Config
Returns a new instance of Config.
10 11 12 13 |
# File 'lib/cors/config.rb', line 10 def initialize(app, user_config = 'config/cors.yml') @app = app @user_config = user_config end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
8 9 10 |
# File 'lib/cors/config.rb', line 8 def app @app end |
#user_config ⇒ Object
Returns the value of attribute user_config.
8 9 10 |
# File 'lib/cors/config.rb', line 8 def user_config @user_config end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/cors/config.rb', line 15 def call(env) config = configure_cors return @app.call(env) if config.empty? cors = generate_cors_rules_from_config(config) return @app.call(env) if cors.nil? cors.call(env) rescue => error raise Error.new("Unexpected error #{error.}") end |