Module: Train::Options::ClassOptions
- Defined in:
- lib/train/options.rb
Instance Method Summary collapse
-
#default_audit_log_options ⇒ Object
Created separate method to set the default audit log options so that it will be handled separately and will not break any existing functionality.
- #default_options ⇒ Object
- #include_options(other) ⇒ Object
- #option(name, conf = nil, &block) ⇒ Object
Instance Method Details
#default_audit_log_options ⇒ Object
Created separate method to set the default audit log options so that it will be handled separately and will not break any existing functionality
39 40 41 42 43 44 45 46 47 |
# File 'lib/train/options.rb', line 39 def { enable_audit_log: { default: false }, audit_log_location: { required: true, default: nil }, audit_log_app_name: { default: "train" }, audit_log_size: { default: nil }, audit_log_frequency: { default: 0 }, } end |
#default_options ⇒ Object
32 33 34 35 |
# File 'lib/train/options.rb', line 32 def @default_options = {} unless defined? @default_options @default_options end |
#include_options(other) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/train/options.rb', line 49 def (other) unless other.respond_to?(:default_options) raise "Trying to include options from module #{other.inspect}, "\ "which doesn't seem to support options." end .merge!(other.) end |
#option(name, conf = nil, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/train/options.rb', line 13 def option(name, conf = nil, &block) d = conf || {} unless d.is_a? Hash raise Train::ClientError, "The transport plugin #{self} declared an option #{name} "\ "and didn't provide a valid configuration hash." end if !conf.nil? && !conf[:default].nil? && block_given? raise Train::ClientError, "The transport plugin #{self} declared an option #{name} "\ "with both a default value and block. Only use one of these." end d[:default] = block if block_given? [name] = d end |