Sha256: 8a33e8f514c7df6e558a1a55756f819c2cc21cd34d277a8a3cc405f39d5d3a07

Contents?: true

Size: 477 Bytes

Versions: 1

Compression:

Stored size: 477 Bytes

Contents

module RequiredOptions
  def required_options(options, *required_options)
    included_opts, missing_opts = required_options.partition do |o|
      options.include?(o)
    end

    raise MissingOptions, exception_text_for(missing_opts) if !missing_opts.empty?
  end

  private
  def exception_text_for(missing_options)
    missing_options.map(&:inspect).join(", ").gsub("\"", "")
  end
end

class Object
  include RequiredOptions
end

class MissingOptions < ArgumentError; end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
required_options-0.6.1 lib/required_options.rb