Module: Train::Options::ClassOptions
- Defined in:
- lib/train/options.rb
Instance Method Summary collapse
- #default_options ⇒ Object
- #include_options(other) ⇒ Object
- #option(name, conf = nil, &block) ⇒ Object
Instance Method Details
#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
37 38 39 40 41 42 43 |
# File 'lib/train/options.rb', line 37 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 |