Class: Rubee::Configuration
- Inherits:
-
Object
- Object
- Rubee::Configuration
- Includes:
- Singleton
- Defined in:
- lib/rubee/configuration.rb
Class Method Summary collapse
- .async_adapter=(args) ⇒ Object
- .database_url=(args) ⇒ Object
- .db_busy_timeout=(args) ⇒ Object
- .db_max_retries=(args) ⇒ Object
- .db_retry_delay=(args) ⇒ Object
- .env ⇒ Object
- .envs(app_name = :app) ⇒ Object
- .fibers_limit=(args) ⇒ Object
- .logger=(args) ⇒ Object
- .method_missing(method_name, *args) ⇒ Object
- .middlewares(**args) ⇒ Object
- .middlewares=(args) ⇒ Object
- .pubsub_container(**args) ⇒ Object
- .pubsub_container=(args) ⇒ Object
- .react(**args) ⇒ Object
- .react=(args) ⇒ Object
- .redis_url=(args) ⇒ Object
- .rubee_support=(value) ⇒ Object
- .setup(env, app = :app) {|_self| ... } ⇒ Object
- .threads_limit=(args) ⇒ Object
Class Method Details
.async_adapter=(args) ⇒ Object
70 71 72 73 |
# File 'lib/rubee/configuration.rb', line 70 def async_adapter=(args) args[:app] ||= :app @configuraiton[args[:app].to_sym][args[:env].to_sym][:async_adapter] = args[:async_adapter] end |
.database_url=(args) ⇒ Object
60 61 62 63 |
# File 'lib/rubee/configuration.rb', line 60 def database_url=(args) args[:app] ||= :app @configuraiton[args[:app].to_sym][args[:env].to_sym][:database_url] = args[:url].gsub("//", "//#{Rubee::LIB}") end |
.db_busy_timeout=(args) ⇒ Object
95 96 97 98 |
# File 'lib/rubee/configuration.rb', line 95 def db_busy_timeout=(args) args[:app] ||= :app @configuraiton[args[:app].to_sym][args[:env].to_sym][:db_busy_timeout] = args[:value] end |
.db_max_retries=(args) ⇒ Object
85 86 87 88 |
# File 'lib/rubee/configuration.rb', line 85 def db_max_retries=(args) args[:app] ||= :app @configuraiton[args[:app].to_sym][args[:env].to_sym][:db_max_retries] = args[:value] end |
.db_retry_delay=(args) ⇒ Object
90 91 92 93 |
# File 'lib/rubee/configuration.rb', line 90 def db_retry_delay=(args) args[:app] ||= :app @configuraiton[args[:app].to_sym][args[:env].to_sym][:db_retry_delay] = args[:value] end |
.env ⇒ Object
20 21 22 |
# File 'lib/rubee/configuration.rb', line 20 def env ENV['RACK_ENV'] end |
.envs(app_name = :app) ⇒ Object
144 145 146 |
# File 'lib/rubee/configuration.rb', line 144 def envs(app_name = :app) @configuraiton[app_name.to_sym].keys end |
.fibers_limit=(args) ⇒ Object
80 81 82 83 |
# File 'lib/rubee/configuration.rb', line 80 def fibers_limit=(args) args[:app] ||= :app @configuraiton[args[:app].to_sym][args[:env].to_sym][:fiber_pool_limit] = args[:value] end |
.logger=(args) ⇒ Object
100 101 102 103 |
# File 'lib/rubee/configuration.rb', line 100 def logger=(args) args[:app] ||= :app @configuraiton[args[:app].to_sym][args[:env].to_sym][:logger] = args[:logger] end |
.method_missing(method_name, *args) ⇒ Object
136 137 138 139 140 141 142 |
# File 'lib/rubee/configuration.rb', line 136 def method_missing(method_name, *args) return unless method_name.to_s.start_with?('get_') app_name = args[0] || :app @configuraiton[app_name.to_sym][ENV['RACK_ENV']&.to_sym || :development] &.[](method_name.to_s.delete_prefix('get_').to_sym) end |
.middlewares(**args) ⇒ Object
126 127 128 129 |
# File 'lib/rubee/configuration.rb', line 126 def middlewares(**args) args[:app] ||= :app @configuraiton[args[:app].to_sym][ENV['RACK_ENV']&.to_sym || :development][:middlewares] || [] end |
.middlewares=(args) ⇒ Object
121 122 123 124 |
# File 'lib/rubee/configuration.rb', line 121 def middlewares=(args) args[:app] ||= :app @configuraiton[args[:app].to_sym][args[:env].to_sym][:middlewares] = args[:middlewares] end |
.pubsub_container(**args) ⇒ Object
131 132 133 134 |
# File 'lib/rubee/configuration.rb', line 131 def pubsub_container(**args) args[:app] ||= :app @configuraiton[args[:app].to_sym][ENV['RACK_ENV']&.to_sym || :development][:pubsub_container] || ::Rubee::PubSub::Redis.instance end |
.pubsub_container=(args) ⇒ Object
116 117 118 119 |
# File 'lib/rubee/configuration.rb', line 116 def pubsub_container=(args) args[:app] ||= :app @configuraiton[args[:app].to_sym][args[:env].to_sym][:pubsub_container] = args[:pubsub_container] end |
.react(**args) ⇒ Object
111 112 113 114 |
# File 'lib/rubee/configuration.rb', line 111 def react(**args) args[:app] ||= :app @configuraiton[args[:app].to_sym][ENV['RACK_ENV']&.to_sym || :development][:react] || {} end |
.react=(args) ⇒ Object
105 106 107 108 109 |
# File 'lib/rubee/configuration.rb', line 105 def react=(args) args[:app] ||= :app @configuraiton[args[:app].to_sym][args[:env].to_sym][:react] ||= { on: false } @configuraiton[args[:app].to_sym][args[:env].to_sym][:react].merge!(on: args[:on]) end |
.redis_url=(args) ⇒ Object
65 66 67 68 |
# File 'lib/rubee/configuration.rb', line 65 def redis_url=(args) args[:app] ||= :app @configuraiton[args[:app].to_sym][args[:env].to_sym][:redis_url] = args[:url] end |
.rubee_support=(value) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rubee/configuration.rb', line 47 def rubee_support=(value) all = value.fetch(:all, false) classes = value.fetch(:classes, []) if all Rubee::RUBEE_SUPPORT.each do |support_string, klass| support_klass = Object.const_get(support_string) klass.include(support_klass) end else classes.each { |klass| Rubee::RUBEE_SUPPORT[klass.to_s].include(klass) } end end |
.setup(env, app = :app) {|_self| ... } ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rubee/configuration.rb', line 24 def setup(env, app = :app) unless @configuraiton[app.to_sym] @configuraiton[app.to_sym] = { development: {}, production: {}, test: {}, } unless @configuraiton[app.to_sym][env.to_sym] @configuraiton[app.to_sym][env.to_sym] = {} end end envs.each do |envi| next if respond_to? "#{envi}?" define_singleton_method "#{envi}?" do envi.to_s == ENV['RACK_ENV'] end end yield(self) end |
.threads_limit=(args) ⇒ Object
75 76 77 78 |
# File 'lib/rubee/configuration.rb', line 75 def threads_limit=(args) args[:app] ||= :app @configuraiton[args[:app].to_sym][args[:env].to_sym][:thread_pool_limit] = args[:value] end |