Module: Train::Options::InstanceOptions
- Defined in:
- lib/train/options.rb
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
Options, which created this Transport.
Instance Method Summary collapse
Instance Attribute Details
#options ⇒ Hash (readonly)
Returns options, which created this Transport.
49 50 51 |
# File 'lib/train/options.rb', line 49 def @options end |
Instance Method Details
#default_options ⇒ Object
51 52 53 |
# File 'lib/train/options.rb', line 51 def self.class. end |
#merge_options(base, opts) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/train/options.rb', line 55 def (base, opts) res = base.merge(opts || {}) .each do |field, hm| next unless res[field].nil? and hm.key?(:default) default = hm[:default] if default.is_a? Proc res[field] = default.call(res) else res[field] = default end end res end |
#validate_options(opts) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/train/options.rb', line 69 def (opts) .each do |field, hm| if opts[field].nil? and hm[:required] fail Train::ClientError, "You must provide a value for #{field.to_s.inspect}." end end opts end |