Class: SalesforceStreamer::Configuration
- Inherits:
-
Object
- Object
- SalesforceStreamer::Configuration
- Defined in:
- lib/salesforce_streamer/configuration.rb
Overview
Manages server configuration.
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#config_file ⇒ Object
Returns the value of attribute config_file.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#exception_adapter ⇒ Object
Returns the value of attribute exception_adapter.
-
#faye_extensions ⇒ Object
readonly
Returns the value of attribute faye_extensions.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#manage_topics ⇒ Object
Returns the value of attribute manage_topics.
-
#middleware ⇒ Object
readonly
Returns the value of attribute middleware.
-
#replay_adapter ⇒ Object
Returns the value of attribute replay_adapter.
-
#require_path ⇒ Object
Returns the value of attribute require_path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #manage_topics? ⇒ Boolean
-
#middleware_runner(last_handler) ⇒ Object
returns a ready to use chain of middleware.
- #push_topic_data ⇒ Object
- #restforce_logger! ⇒ Object
-
#use_faye_extension(extension) ⇒ Object
adds a Faye extension.
-
#use_middleware(klass, *args, &block) ⇒ Object
adds a setup proc to the middleware array.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/salesforce_streamer/configuration.rb', line 20 def initialize @environment = ENV['RACK_ENV'] || :development @logger = Logger.new(IO::NULL) @exception_adapter = proc { |exc| fail(exc) } @replay_adapter = Hash.new { |hash, key| hash[key] = -1 } @manage_topics = false @config_file = './config/streamer.yml' @require_path = './config/environment' @middleware = [] @faye_extensions = [ReplayIdErrorExtension.new] end |
Class Attribute Details
.instance ⇒ Object
15 16 17 |
# File 'lib/salesforce_streamer/configuration.rb', line 15 def instance @instance ||= new end |
Instance Attribute Details
#config_file ⇒ Object
Returns the value of attribute config_file.
4 5 6 |
# File 'lib/salesforce_streamer/configuration.rb', line 4 def config_file @config_file end |
#environment ⇒ Object
Returns the value of attribute environment.
4 5 6 |
# File 'lib/salesforce_streamer/configuration.rb', line 4 def environment @environment end |
#exception_adapter ⇒ Object
Returns the value of attribute exception_adapter.
4 5 6 |
# File 'lib/salesforce_streamer/configuration.rb', line 4 def exception_adapter @exception_adapter end |
#faye_extensions ⇒ Object (readonly)
Returns the value of attribute faye_extensions.
6 7 8 |
# File 'lib/salesforce_streamer/configuration.rb', line 6 def faye_extensions @faye_extensions end |
#logger ⇒ Object
Returns the value of attribute logger.
4 5 6 |
# File 'lib/salesforce_streamer/configuration.rb', line 4 def logger @logger end |
#manage_topics ⇒ Object
Returns the value of attribute manage_topics.
4 5 6 |
# File 'lib/salesforce_streamer/configuration.rb', line 4 def manage_topics @manage_topics end |
#middleware ⇒ Object (readonly)
Returns the value of attribute middleware.
6 7 8 |
# File 'lib/salesforce_streamer/configuration.rb', line 6 def middleware @middleware end |
#replay_adapter ⇒ Object
Returns the value of attribute replay_adapter.
4 5 6 |
# File 'lib/salesforce_streamer/configuration.rb', line 4 def replay_adapter @replay_adapter end |
#require_path ⇒ Object
Returns the value of attribute require_path.
4 5 6 |
# File 'lib/salesforce_streamer/configuration.rb', line 4 def require_path @require_path end |
Class Method Details
.configure {|instance| ... } ⇒ Object
11 12 13 |
# File 'lib/salesforce_streamer/configuration.rb', line 11 def configure yield instance end |
Instance Method Details
#manage_topics? ⇒ Boolean
32 33 34 |
# File 'lib/salesforce_streamer/configuration.rb', line 32 def manage_topics? @manage_topics end |
#middleware_runner(last_handler) ⇒ Object
returns a ready to use chain of middleware
47 48 49 50 51 52 |
# File 'lib/salesforce_streamer/configuration.rb', line 47 def middleware_runner(last_handler) @middleware.reduce(last_handler) do |next_handler, current_handler| klass, args, block = current_handler klass.new(next_handler, *args, &block) end end |
#push_topic_data ⇒ Object
54 55 56 57 58 59 |
# File 'lib/salesforce_streamer/configuration.rb', line 54 def push_topic_data return @push_topic_data if @push_topic_data data = YAML.safe_load_file(config_file, aliases: true) @push_topic_data = data[environment.to_s] || data end |
#restforce_logger! ⇒ Object
61 62 63 |
# File 'lib/salesforce_streamer/configuration.rb', line 61 def restforce_logger! Restforce.log = true end |
#use_faye_extension(extension) ⇒ Object
adds a Faye extension
42 43 44 |
# File 'lib/salesforce_streamer/configuration.rb', line 42 def use_faye_extension(extension) @faye_extensions << extension end |
#use_middleware(klass, *args, &block) ⇒ Object
adds a setup proc to the middleware array
37 38 39 |
# File 'lib/salesforce_streamer/configuration.rb', line 37 def use_middleware(klass, *args, &block) @middleware << [klass, args, block] end |