module Train::Options::ClassOptions
Public Instance Methods
default_options()
click to toggle source
# File lib/train/options.rb, line 33 def default_options @default_options = {} unless defined? @default_options @default_options end
include_options(other)
click to toggle source
# File lib/train/options.rb, line 38 def include_options(other) unless other.respond_to?(:default_options) fail "Trying to include options from module #{other.inspect}, "\ "which doesn't seem to support options." end default_options.merge!(other.default_options) end
option(name, conf = nil, &block)
click to toggle source
# File lib/train/options.rb, line 14 def option(name, conf = nil, &block) d = conf || {} unless d.is_a? Hash fail Train::ClientError, "The transport plugin #{self} declared an option #{name} "\ "and didn't provide a valid configuration hash." end if !conf.nil? and !conf[:default].nil? and block_given? fail 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? default_options[name] = d end